<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Buck Woody : Development, Developer, Tutorials</title><link>http://sqlblog.com/blogs/buck_woody/archive/tags/Development/Developer/Tutorials/default.aspx</link><description>Tags: Development, Developer, Tutorials</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Windows Azure End to End Examples</title><link>http://sqlblog.com/blogs/buck_woody/archive/2012/05/29/windows-azure-end-to-end-examples.aspx</link><pubDate>Tue, 29 May 2012 13:45:59 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:43642</guid><dc:creator>BuckWoody</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/43642.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=43642</wfw:commentRss><description>&lt;p&gt;I’m fascinated by the way people learn. I’m told there are several methods people use to understand new information, from reading to watching, from experiencing to exploring. &lt;/p&gt;  &lt;p&gt;Personally, I use multiple methods of learning when I encounter a new topic, usually starting with reading a bit about the concepts. I quickly want to put those into practice, however, especially in the technical realm. I immediately look for examples where I can start trying out the concepts. But I often want a “real” example – not just something that represents the concept, but something that is real-world, showing some feature I could actually use. &lt;/p&gt;  &lt;p&gt;And it’s no different with the Windows Azure platform – I like finding things I can do now, and actually use. So when I started learning Windows Azure, &lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=8396" target="_blank"&gt;I of course began with the Windows Azure Training Kit&lt;/a&gt; – which has lots of examples and labs, presentations and so on. But from there, I wanted more examples I could learn from, and eventually teach others with. I was asked if I would write a few of those up, so here are the ones I use. &lt;/p&gt;  &lt;h2&gt;CodePlex&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://www.codeplex.com/" target="_blank"&gt;CodePlex is Microsoft’s version of an “Open Source” repository&lt;/a&gt;. Anyone can start a project, add code, documentation and more to it and make it available to the world, free of charge, using various licenses as they wish. Microsoft also uses this location for most of the examples we publish, and sample databases for SQL Server. &lt;/p&gt;  &lt;p&gt;If you search in CodePlex for “Azure”, you’ll come back with a list of projects that folks have posted, including those of us at Microsoft. The source code and documentation are there, so you can learn using actual examples of code that will do what you need. There’s everything from a simple table query to &lt;a href="http://blobshare.codeplex.com/" target="_blank"&gt;a full project that is sort of a “Corporate Dropbox” that uses Windows Azure Storage&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;The advantage is that this code is immediately usable. It’s searchable, and you can often find a complete solution to meet your needs. The disadvantage is that the code is pretty specific – it may not cover a huge project like you’re looking for. Also, depending on the author(s), you might not find the documentation level you want. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;Link: &lt;a href="http://azureexamples.codeplex.com/site/search?query=Azure&amp;amp;ac=8"&gt;http://azureexamples.codeplex.com/site/search?query=Azure&amp;amp;ac=8&lt;/a&gt;&amp;#160;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Tailspin&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/practices/default" target="_blank"&gt;Microsoft Patterns and Practices&lt;/a&gt; is a group here that does an amazing job at sharing standard ways of doing IT – from operations to coding. If you’re not familiar with this resource, make sure you read up on it. Long before I joined Microsoft I used their work in my daily job – saved a ton of time. It has resources not only for Windows Azure but other Microsoft software as well. &lt;/p&gt;  &lt;p&gt;The Patterns and Practices group also publishes full books – you can buy these, but many are also online for free. There’s an end-to-end example for Windows Azure using a company called “Tailspin”, and the work covers not only the code but the design of the full solution. If you really want to understand the thought that goes into a Platform-as-a-Service solution, this is an excellent resource. &lt;/p&gt;  &lt;p&gt;The advantages are that this is a book, it’s complete, and it includes a discussion of design decisions. The disadvantage is that it’s a little over a year old – and in “Cloud” years that’s a lot. So many things have changed, improved, and have been added that you need to treat this as a resource, but not the only one. Still, highly recommended. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;Link: &lt;a href="http://msdn.microsoft.com/en-us/library/ff728592.aspx"&gt;http://msdn.microsoft.com/en-us/library/ff728592.aspx&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;h2&gt;Azure Stock Trader&lt;/h2&gt;  &lt;p&gt;Sometimes you need a mix of a CodePlex-style application, and a little more detail on how it was put together. And it would be great if you could actually play with the completed application, to see how it really functions on the actual platform.&lt;/p&gt;  &lt;p&gt;That’s the Azure Stock Trader application. There’s a place where you can read about the application, and then it’s been published to Windows Azure – the production platform – and you can use it, explore, and see how it performs. &lt;/p&gt;  &lt;p&gt;I use this application all the time to demonstrate Windows Azure, or a particular part of Windows Azure.&lt;/p&gt;  &lt;p&gt;The advantage is that this is an end-to-end application, and online as well. The disadvantage is that it takes a bit of self-learning to work through.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;Links: Learn it: &lt;a href="http://msdn.microsoft.com/en-us/netframework/bb499684"&gt;http://msdn.microsoft.com/en-us/netframework/bb499684&lt;/a&gt; Use it: &lt;a href="https://azurestocktrader.cloudapp.net/"&gt;https://azurestocktrader.cloudapp.net/&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=43642" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Azure/default.aspx">Azure</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Cloud/default.aspx">Cloud</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Cloud+Computing/default.aspx">Cloud Computing</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Concepts/default.aspx">Concepts</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Downloads/default.aspx">Downloads</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/How+I+work/default.aspx">How I work</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Learning/default.aspx">Learning</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Link+Lists/default.aspx">Link Lists</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Links/default.aspx">Links</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/MSDN/default.aspx">MSDN</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Planning/default.aspx">Planning</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Presentations/default.aspx">Presentations</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Azure/default.aspx">SQL Azure</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Technet/default.aspx">Technet</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tips/default.aspx">Tips</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tutorials/default.aspx">Tutorials</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Walkthroughs/default.aspx">Walkthroughs</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Web/default.aspx">Web</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Windows+Azure/default.aspx">Windows Azure</category></item><item><title>Code that Writes Code</title><link>http://sqlblog.com/blogs/buck_woody/archive/2009/11/25/code-that-writes-code.aspx</link><pubDate>Wed, 25 Nov 2009 14:01:40 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:19171</guid><dc:creator>BuckWoody</dc:creator><slash:comments>5</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/19171.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=19171</wfw:commentRss><description>&lt;p&gt;I have scripts that re-create my databases for testing and development purposes. But sometimes I want to take the data from a set of tables and move it as well – I could use SSIS, or a SELECT INTO statement, but what if I want to “re-set” the data to a point in time? In other words, load it with some “base data”? &lt;/p&gt;  &lt;p&gt;I thought this might be a good place to demonstrate “code that writes code”. No, it isn’t that big of a deal – most DBAs know how to do this, but in the interest of those who don’t, I thought I would share.&lt;/p&gt;  &lt;p&gt;So the end result I want in this case is to have a bunch of INSERT statements that contain my base data from a table where that data already exists. I could script out the table from SSMS and use the replacement parameter feature to fill out each record individually:&lt;/p&gt;  &lt;p&gt;I have a table in one of my databases that I right-clicked to show the INSERT statement:&lt;/p&gt; &lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;     &lt;p&gt;-- Person&lt;/p&gt;   &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;     &lt;p&gt;INSERT&lt;/p&gt;   &lt;/font&gt;&lt;font color="#000000" size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;INTO&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; [WAVS]&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;[dbo]&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;[Person]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;[PersonName]&lt;/font&gt;&lt;/font&gt;    &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[Street]&lt;/font&gt;    &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[CityStateZip]&lt;/font&gt;    &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[PersonType]&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;   &lt;p&gt;&lt;/p&gt;   &lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;VALUES&lt;/font&gt;      &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;PersonName&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;varchar&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;150&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;),&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;   &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;PersonStreet&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;varchar&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;100&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;),&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;   &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;PersonCityStateZip&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;varchar&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;255&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;),&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;   &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;PersonPersonType&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;varchar&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;100&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;),&amp;gt;)&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;&lt;font color="#333333" size="2"&gt;I can use the CTRL-SHIFT-M keys to replace the VALUES part with the values I want.&amp;#160; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;&lt;font color="#333333" size="2"&gt;But I already had a copy of that “base” data before I turned the database over to the testers. Before I give it to them, I run code like this on each table – this one is for the &lt;em&gt;Person&lt;/em&gt; table above (note that there should only be two lines here):&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;font color="#808080"&gt;&lt;font color="#808080"&gt;&lt;font color="#333333"&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;           &lt;p&gt;&lt;font size="2"&gt;SELECT&lt;/font&gt;&lt;/p&gt;         &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;'INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES ('&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff00ff"&gt;&lt;font color="#ff00ff"&gt;CAST&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt;[PersonID] &lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;AS&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;VARCHAR&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt;5&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;))+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;', '''&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; [PersonName]&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;''', '''&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; [Street]&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;''', '''&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; [CityStateZip] &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;''', '''&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; [PersonType] &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;''')'&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;           &lt;p&gt;&lt;font size="2"&gt;FROM&lt;/font&gt;&lt;/p&gt;         &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; [WAVS]&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt;[dbo]&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt;[Person]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;        &lt;p&gt;&lt;font color="#000000" size="2"&gt;When I run this code, I get these statements:&lt;/font&gt;&lt;/p&gt;        &lt;p&gt;&lt;font color="#0080c0" size="2"&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (1, 'Buck Woody', '123 Here Street', 'Covington, WA 98042', 'Vet')           &lt;br /&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (2, 'Jane Doe', '231 Function Ave', 'Redmond, WA 98052', 'Vet')            &lt;br /&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (3, 'Diane Wilson', '34251 Appt 3 7th Street', 'Seattle, WA 98061', 'Vet')            &lt;br /&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (4, 'John Kelso', '89734 Country Lane', 'Covington, WA 98042', 'Farmer')            &lt;br /&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (5, 'Marjorie Christian', '9893452 Changein Lane', 'Maple Valley, WA 98072', 'Farmer')            &lt;br /&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (6, 'Joanne Lister', '98904 Mapelwood Drive', 'Spokanne, WA 98045', 'Zoo Worker')&lt;/font&gt;&lt;/p&gt;        &lt;p&gt;&lt;font size="2"&gt;All I have to do is copy those statements into my “initialization” scripts just after the table creations, and then I can run them at will to create my new database (I know I can take a backup – I have reasons for not doing that).&lt;/font&gt;&lt;/p&gt;        &lt;p&gt;&lt;font size="2"&gt;There are two keys for writing code that writes code: The first is to simply use the single tick (') to write out what the end code should say (INSERT INTO, in my case) and then to use multiple ticks (''') when you want the code to contain the ticks themselves. This “escapes” the characters so that you can embed them. If you use SSMS to write your queries, the color coding will look as mine does above. You’ll also need to remember to CAST or CONVERT any data types that don’t concatenate (+) together well. In my case I had to CAST an integer value – but that’s OK, since it is only printing to the screen and I don’t include the ticks, the INSERT works fine.&lt;/font&gt;&lt;/p&gt;        &lt;p&gt;&lt;font size="2"&gt;You can use this method not only with INSERTS, but with lots of operations. And you can also even fire off the code once you create it – but that’s another post :)&lt;/font&gt;&lt;/p&gt;        &lt;p&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=19171" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Scripts/default.aspx">Scripts</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server+Management+Studio/default.aspx">SQL Server Management Studio</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SSMS/default.aspx">SSMS</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tips/default.aspx">Tips</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/T-SQL/default.aspx">T-SQL</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tutorials/default.aspx">Tutorials</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Virtualization/default.aspx">Virtualization</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Web/default.aspx">Web</category></item></channel></rss>