<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:georss="http://www.georss.org/georss" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Static Void - Codeplex</title>
    <link>http://martinwilley.com/blog/</link>
    <description>What next?</description>
    <language>en-us</language>
    <copyright>Martin Willey</copyright>
    <lastBuildDate>Mon, 25 Apr 2011 10:13:17 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>me@martinwilley.com</managingEditor>
    <webMaster>me@martinwilley.com</webMaster>
    <item>
      <trackback:ping>http://martinwilley.com/blog/Trackback.aspx?guid=2374a274-7c2e-49a4-808f-8b33799b4fe3</trackback:ping>
      <pingback:server>http://martinwilley.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://martinwilley.com/blog/PermaLink,guid,2374a274-7c2e-49a4-808f-8b33799b4fe3.aspx</pingback:target>
      <dc:creator>Martin</dc:creator>
      <wfw:comment>http://martinwilley.com/blog/CommentView,guid,2374a274-7c2e-49a4-808f-8b33799b4fe3.aspx</wfw:comment>
      <wfw:commentRss>http://martinwilley.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=2374a274-7c2e-49a4-808f-8b33799b4fe3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Shortly after the last release of <a href="http://dbschemareader.codeplex.com/" target="_blank">Database
Schema Reader</a>, here's another release.
</p>
        <p>
          <a href="http://martinwilley.com/blog/2011/04/09/DatabaseSchemaReaderNowWithExtraSQLite.aspx" target="_blank">Last
time</a> I added a CopyToSQLite tool, which reads (almost) any database and creates
a SQLite clone. I also added experimental support for SQLServer CE 4.0, but it had
some big limitations. 
</p>
        <p>
So the obvious next step was to fix some of those limitations, and that's what this
release focuses on. Unfortunately CopyToSQLite.exe is now a little misnamed. <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://www.martinwilley.com/blog/content/binary/Database-Schema-Reader-with-more-.0-love_9CD7/wlEmoticon-winkingsmile.png" /></p>
        <p>
I added a little bit of conversion code so VARCHAR(MAX) found in the origin database
gets converted to NTEXT (and VARBINARY to IMAGE). The reading of SQLServer CE 4 databases
got improved too (capturing the  foreign and unique keys and identity columns).
</p>
        <p>
SQLServer allows an integer column to be marked as "Identity" so it will be auto-generated
(the equivalent in Oracle is to create a sequence and an insert trigger). But you
can't include the identity column when you insert a row. So, when cloning data, SQLServer
also allows identity-inserts with SET IDENTITY_INSERT [MyTable] ON/OFF. When you've
done that, you should reset the identity seed with DBCC CHECKIDENT.
</p>
        <p>
But in SQLServer CE 4, there is no DBCC CHECKIDENT. You have to do an ALTER TABLE
[MyTable] ALTER COLUMN [IdentityColumn] IDENTITY (999,1) (where 999 is the new max(IdentityColumn)).
It's another of those little gotchas between SQLServer and SQLServer CE.
</p>
        <p>
SQLServer CE 4 has some great new paging syntax:
</p>
        <p>
SELECT Id, Name FROM MyTable 
<br />
ORDER BY Name 
<br />
OFFSET 10 ROWS 
<br />
FETCH NEXT 5 ROWS ONLY
</p>
        <p>
It's similar to the LIMIT/OFFSET syntax in MySQL and SQLite, but (reasonably enough)
must follow an ORDER BY. Rather than offset/skipping a number of rows, I'd like to
specify just page number and page size - or another formula. The <a href="http://msdn.microsoft.com/en-us/library/ms188385%28v=sql.110%29.aspx#Offset" target="_blank">SQLServer
2011/Denali documentation</a> shows the offset/fetch syntax for a start row/end row
expression:
</p>
        <p>
SELECT DepartmentID, Name, GroupName 
<br />
FROM HumanResources.Department 
<br />
ORDER BY DepartmentID ASC 
<br />
OFFSET @StartingRowNumber - 1 ROWS 
<br />
FETCH NEXT @EndingRowNumber - @StartingRowNumber + 1 ROWS ONLY
</p>
        <p>
But that doesn't work in SQLServer CE 4. You can use parameters, or constants, or
expressions with constants, but apparently not expressions with constants and parameters.
Oh well, it's still much better than horrible OVER subqueries.<br /></p>
        <p>
Overall, the "CopyToSQLite" to SQLServer CE 4 seems to work well. Using easily deployable
file databases like SQLServer CE and SQLite is simple and powerful. 
</p>
        <img width="0" height="0" src="http://martinwilley.com/blog/aggbug.ashx?id=2374a274-7c2e-49a4-808f-8b33799b4fe3" />
      </body>
      <title>Database Schema Reader with more SqlServerCE 4.0 love</title>
      <guid isPermaLink="false">http://martinwilley.com/blog/PermaLink,guid,2374a274-7c2e-49a4-808f-8b33799b4fe3.aspx</guid>
      <link>http://martinwilley.com/blog/2011/04/25/DatabaseSchemaReaderWithMoreSqlServerCE40Love.aspx</link>
      <pubDate>Mon, 25 Apr 2011 10:13:17 GMT</pubDate>
      <description>&lt;p&gt;
Shortly after the last release of &lt;a href="http://dbschemareader.codeplex.com/" target="_blank"&gt;Database
Schema Reader&lt;/a&gt;, here's another release.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://martinwilley.com/blog/2011/04/09/DatabaseSchemaReaderNowWithExtraSQLite.aspx" target="_blank"&gt;Last
time&lt;/a&gt; I added a CopyToSQLite tool, which reads (almost) any database and creates
a SQLite clone. I also added experimental support for SQLServer CE 4.0, but it had
some big limitations. 
&lt;/p&gt;
&lt;p&gt;
So the obvious next step was to fix some of those limitations, and that's what this
release focuses on. Unfortunately CopyToSQLite.exe is now a little misnamed. &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://www.martinwilley.com/blog/content/binary/Database-Schema-Reader-with-more-.0-love_9CD7/wlEmoticon-winkingsmile.png"&gt;
&lt;/p&gt;
&lt;p&gt;
I added a little bit of conversion code so VARCHAR(MAX) found in the origin database
gets converted to NTEXT (and VARBINARY to IMAGE). The reading of SQLServer CE 4 databases
got improved too (capturing the&amp;nbsp; foreign and unique keys and identity columns).
&lt;/p&gt;
&lt;p&gt;
SQLServer allows an integer column to be marked as "Identity" so it will be auto-generated
(the equivalent in Oracle is to create a sequence and an insert trigger). But you
can't include the identity column when you insert a row. So, when cloning data, SQLServer
also allows identity-inserts with SET IDENTITY_INSERT [MyTable] ON/OFF. When you've
done that, you should reset the identity seed with DBCC CHECKIDENT.
&lt;/p&gt;
&lt;p&gt;
But in SQLServer CE 4, there is no DBCC CHECKIDENT. You have to do an ALTER TABLE
[MyTable] ALTER COLUMN [IdentityColumn] IDENTITY (999,1) (where 999 is the new max(IdentityColumn)).
It's another of those little gotchas between SQLServer and SQLServer CE.
&lt;/p&gt;
&lt;p&gt;
SQLServer CE 4 has some great new paging syntax:
&lt;/p&gt;
&lt;p&gt;
SELECT Id, Name FROM MyTable 
&lt;br&gt;
ORDER BY Name 
&lt;br&gt;
OFFSET 10 ROWS 
&lt;br&gt;
FETCH NEXT 5 ROWS ONLY
&lt;/p&gt;
&lt;p&gt;
It's similar to the LIMIT/OFFSET syntax in MySQL and SQLite, but (reasonably enough)
must follow an ORDER BY. Rather than offset/skipping a number of rows, I'd like to
specify just page number and page size - or another formula. The &lt;a href="http://msdn.microsoft.com/en-us/library/ms188385%28v=sql.110%29.aspx#Offset" target="_blank"&gt;SQLServer
2011/Denali documentation&lt;/a&gt; shows the offset/fetch syntax for a start row/end row
expression:
&lt;/p&gt;
&lt;p&gt;
SELECT DepartmentID, Name, GroupName 
&lt;br&gt;
FROM HumanResources.Department 
&lt;br&gt;
ORDER BY DepartmentID ASC 
&lt;br&gt;
OFFSET @StartingRowNumber - 1 ROWS 
&lt;br&gt;
FETCH NEXT @EndingRowNumber - @StartingRowNumber + 1 ROWS ONLY
&lt;/p&gt;
&lt;p&gt;
But that doesn't work in SQLServer CE 4. You can use parameters, or constants, or
expressions with constants, but apparently not expressions with constants and parameters.
Oh well, it's still much better than horrible OVER subqueries.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
Overall, the "CopyToSQLite" to SQLServer CE 4 seems to work well. Using easily deployable
file databases like SQLServer CE and SQLite is simple and powerful. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://martinwilley.com/blog/aggbug.ashx?id=2374a274-7c2e-49a4-808f-8b33799b4fe3" /&gt;</description>
      <comments>http://martinwilley.com/blog/CommentView,guid,2374a274-7c2e-49a4-808f-8b33799b4fe3.aspx</comments>
      <category>Codeplex</category>
      <category>Database Schema Reader</category>
      <category>SqlServerCe</category>
    </item>
    <item>
      <trackback:ping>http://martinwilley.com/blog/Trackback.aspx?guid=b8fbbe6a-5e86-4963-a561-52f6b8aeb4e9</trackback:ping>
      <pingback:server>http://martinwilley.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://martinwilley.com/blog/PermaLink,guid,b8fbbe6a-5e86-4963-a561-52f6b8aeb4e9.aspx</pingback:target>
      <dc:creator>Martin</dc:creator>
      <wfw:comment>http://martinwilley.com/blog/CommentView,guid,b8fbbe6a-5e86-4963-a561-52f6b8aeb4e9.aspx</wfw:comment>
      <wfw:commentRss>http://martinwilley.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=b8fbbe6a-5e86-4963-a561-52f6b8aeb4e9</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
My Codeplex project, <a href="http://dbschemareader.codeplex.com/" target="_blank">Database
Schema Reader</a>, has a new version.
</p>
        <p>
I needed to create a SQLite database was a replica of a parent SQL Server database.
The existing project could easily read the schema, and the code generation tools could
give me the table DDL and the insert SQL. It was just a matter of executing the SQL
and creating the database file. 
</p>
        <p>
So I created another simple Windows Forms UI. The SqlWriter class needed some tweaks
for SQLite support (and I added integration tests).
</p>
        <p>
For fun, I decided to see if it could also support Microsoft's latest version of SQL
Server CE 4.0. 
</p>
        <p>
SQL Server CE 4.0 is, like SQLite, an in-process database which can be XCOPY deployed.
And unlike previous versions, it is easily able to run ASP.Net websites (it's the
default database behind WebMatrix). And 4.0 provides the standard ADO GetSchema which
my Database Schema Reader uses (3.5 throws a Not Implemented exception).
</p>
        <p>
It has some of the same limitations as SQLite, such as no stored procedures (good
riddance), and no output parameters. But it also has additional limitations. In SQLite
you can batch together multiple SQL statements in a single line and execute them in
one command. You can't in SQL Server CE.
</p>
        <p>
Unlike SQLite's weakly typed and very simple data types, SQL Server CE 4.0 has most
of the standard data types as SQL Server Express and full versions. Unfortunately,
this was the big problem. If your table is defined with an IDENTITY primary key, you
can't insert the data row with the same primary key, and subsequent foreign key relationships
are broken. It's a pretty critical limitation for my scenario. 
</p>
        <p>
SQL Server CE 4 only supports a subset of SQL Server data types. The one data type
it didn't support, which my database (and later versions of Northwind) use, is NVARCHAR(MAX).
You have to use the horrible old NTEXT data type. I could have written a DDL provider
that translates varchar max to ntext, but I don't think it's worth the effort.
</p>
        <p>
So my SQL Server CE creation program has major limitations, compared to the SQLite
version. It's built into CopyToSQLite.exe, and auto-detects if you've installed SQL
Server CE, but you have to have a very simple database for it to work.
</p>
        <p>
SQL Server CE 4 also doesn't support the ADO Sync framework which allows you to synchronize
a disconnected database to a parent SQL Server database. Even SQL Server 2008 R2 Management
Studio doesn't support it (you have to use Visual Studio 2010 with SP1).
</p>
        <p>
The new FETCH /OFFSET syntax for paging, that will be SQL Server 11, is very nice
though. I'm looking forward to that.
</p>
        <img width="0" height="0" src="http://martinwilley.com/blog/aggbug.ashx?id=b8fbbe6a-5e86-4963-a561-52f6b8aeb4e9" />
      </body>
      <title>Database Schema Reader now with extra SQLite</title>
      <guid isPermaLink="false">http://martinwilley.com/blog/PermaLink,guid,b8fbbe6a-5e86-4963-a561-52f6b8aeb4e9.aspx</guid>
      <link>http://martinwilley.com/blog/2011/04/09/DatabaseSchemaReaderNowWithExtraSQLite.aspx</link>
      <pubDate>Sat, 09 Apr 2011 18:05:41 GMT</pubDate>
      <description>&lt;p&gt;
My Codeplex project, &lt;a href="http://dbschemareader.codeplex.com/" target="_blank"&gt;Database
Schema Reader&lt;/a&gt;, has a new version.
&lt;/p&gt;
&lt;p&gt;
I needed to create a SQLite database was a replica of a parent SQL Server database.
The existing project could easily read the schema, and the code generation tools could
give me the table DDL and the insert SQL. It was just a matter of executing the SQL
and creating the database file. 
&lt;/p&gt;
&lt;p&gt;
So I created another simple Windows Forms UI. The SqlWriter class needed some tweaks
for SQLite support (and I added integration tests).
&lt;/p&gt;
&lt;p&gt;
For fun, I decided to see if it could also support Microsoft's latest version of SQL
Server CE 4.0. 
&lt;/p&gt;
&lt;p&gt;
SQL Server CE 4.0 is, like SQLite, an in-process database which can be XCOPY deployed.
And unlike previous versions, it is easily able to run ASP.Net websites (it's the
default database behind WebMatrix). And 4.0 provides the standard ADO GetSchema which
my Database Schema Reader uses (3.5 throws a Not Implemented exception).
&lt;/p&gt;
&lt;p&gt;
It has some of the same limitations as SQLite, such as no stored procedures (good
riddance), and no output parameters. But it also has additional limitations. In SQLite
you can batch together multiple SQL statements in a single line and execute them in
one command. You can't in SQL Server CE.
&lt;/p&gt;
&lt;p&gt;
Unlike SQLite's weakly typed and very simple data types, SQL Server CE 4.0 has most
of the standard data types as SQL Server Express and full versions. Unfortunately,
this was the big problem. If your table is defined with an IDENTITY primary key, you
can't insert the data row with the same primary key, and subsequent foreign key relationships
are broken. It's a pretty critical limitation for my scenario. 
&lt;/p&gt;
&lt;p&gt;
SQL Server CE 4 only supports a subset of SQL Server data types. The one data type
it didn't support, which my database (and later versions of Northwind) use, is NVARCHAR(MAX).
You have to use the horrible old NTEXT data type. I could have written a DDL provider
that translates varchar max to ntext, but I don't think it's worth the effort.
&lt;/p&gt;
&lt;p&gt;
So my SQL Server CE creation program has major limitations, compared to the SQLite
version. It's built into CopyToSQLite.exe, and auto-detects if you've installed SQL
Server CE, but you have to have a very simple database for it to work.
&lt;/p&gt;
&lt;p&gt;
SQL Server CE 4 also doesn't support the ADO Sync framework which allows you to synchronize
a disconnected database to a parent SQL Server database. Even SQL Server 2008 R2 Management
Studio doesn't support it (you have to use Visual Studio 2010 with SP1).
&lt;/p&gt;
&lt;p&gt;
The new FETCH /OFFSET syntax for paging, that will be SQL Server 11, is very nice
though. I'm looking forward to that.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://martinwilley.com/blog/aggbug.ashx?id=b8fbbe6a-5e86-4963-a561-52f6b8aeb4e9" /&gt;</description>
      <comments>http://martinwilley.com/blog/CommentView,guid,b8fbbe6a-5e86-4963-a561-52f6b8aeb4e9.aspx</comments>
      <category>.net 4</category>
      <category>Codeplex</category>
      <category>Database Schema Reader</category>
    </item>
    <item>
      <trackback:ping>http://martinwilley.com/blog/Trackback.aspx?guid=09195658-ab1c-4c53-a1bd-b8a63e3ee3be</trackback:ping>
      <pingback:server>http://martinwilley.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://martinwilley.com/blog/PermaLink,guid,09195658-ab1c-4c53-a1bd-b8a63e3ee3be.aspx</pingback:target>
      <dc:creator>Martin</dc:creator>
      <wfw:comment>http://martinwilley.com/blog/CommentView,guid,09195658-ab1c-4c53-a1bd-b8a63e3ee3be.aspx</wfw:comment>
      <wfw:commentRss>http://martinwilley.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=09195658-ab1c-4c53-a1bd-b8a63e3ee3be</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A long time ago I wrote my <a href="http://www.martinwilley.com/net/code/dbschema/dbschema.html" target="_blank">database
schema reader</a>. It was 2005, .Net 2.0 was just out and I was learning about the
new features. .Net 2.0's ADO DbProviderFactory had a nice idea, GetSchema, to get
database independent schema information. But the GetSchema collections were slightly
different for each database, and they were data tables. So I wrote a simple facade
over them to get proper classes.
</p>
        <p>
Initially I used it to generate CRUD stored procedures, and then to generate data
access code, even including NHibernate mappings. I even did some (simple) database
conversions. All this was quite icky, and each time I did the code-gen a different
way, but the core facade worked well. 
</p>
        <p>
After getting a couple of queries about <a href="http://www.martinwilley.com/net/code/dbschema/databaseschema.html" target="_blank">the
extracts I'd already posted</a>, I thought I might as well put up the entire source
code. So here's <a href="http://dbschemareader.codeplex.com/" target="_blank">the
codeplex project</a> with the source code, and even some basic SQL code-gen.
</p>
        <p>
I picked Codeplex just because it's more .Net-centric than Google code or github,
plus I'm more familiar with TFS and Subversion source control. It was pretty easy.
I don't expect many downloads (if any!), but maybe a couple of people can steal the
relevant bits of source code.
</p>
        <p>
Check out the <a href="http://dbschemareader.codeplex.com/" target="_blank">database
schema reader codeplex project</a>.
</p>
        <img width="0" height="0" src="http://martinwilley.com/blog/aggbug.ashx?id=09195658-ab1c-4c53-a1bd-b8a63e3ee3be" />
      </body>
      <title>Database Schema Reader</title>
      <guid isPermaLink="false">http://martinwilley.com/blog/PermaLink,guid,09195658-ab1c-4c53-a1bd-b8a63e3ee3be.aspx</guid>
      <link>http://martinwilley.com/blog/2010/11/01/DatabaseSchemaReader.aspx</link>
      <pubDate>Mon, 01 Nov 2010 11:59:33 GMT</pubDate>
      <description>&lt;p&gt;
A long time ago I wrote my &lt;a href="http://www.martinwilley.com/net/code/dbschema/dbschema.html" target="_blank"&gt;database
schema reader&lt;/a&gt;. It was 2005, .Net 2.0 was just out and I was learning about the
new features. .Net 2.0's ADO DbProviderFactory had a nice idea, GetSchema, to get
database independent schema information. But the GetSchema collections were slightly
different for each database, and they were data tables. So I wrote a simple facade
over them to get proper classes.
&lt;/p&gt;
&lt;p&gt;
Initially I used it to generate CRUD stored procedures, and then to generate data
access code, even including NHibernate mappings. I even did some (simple) database
conversions. All this was quite icky, and each time I did the code-gen a different
way, but the core facade worked well. 
&lt;/p&gt;
&lt;p&gt;
After getting a couple of queries about &lt;a href="http://www.martinwilley.com/net/code/dbschema/databaseschema.html" target="_blank"&gt;the
extracts I'd already posted&lt;/a&gt;, I thought I might as well put up the entire source
code. So here's &lt;a href="http://dbschemareader.codeplex.com/" target="_blank"&gt;the
codeplex project&lt;/a&gt; with the source code, and even some basic SQL code-gen.
&lt;/p&gt;
&lt;p&gt;
I picked Codeplex just because it's more .Net-centric than Google code or github,
plus I'm more familiar with TFS and Subversion source control. It was pretty easy.
I don't expect many downloads (if any!), but maybe a couple of people can steal the
relevant bits of source code.
&lt;/p&gt;
&lt;p&gt;
Check out the &lt;a href="http://dbschemareader.codeplex.com/" target="_blank"&gt;database
schema reader codeplex project&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://martinwilley.com/blog/aggbug.ashx?id=09195658-ab1c-4c53-a1bd-b8a63e3ee3be" /&gt;</description>
      <comments>http://martinwilley.com/blog/CommentView,guid,09195658-ab1c-4c53-a1bd-b8a63e3ee3be.aspx</comments>
      <category>.net 4</category>
      <category>Codeplex</category>
      <category>VS2010</category>
    </item>
  </channel>
</rss>