Buck Woody : Web, Developmenthttp://sqlblog.com/blogs/buck_woody/archive/tags/Web/Development/default.aspxTags: Web, DevelopmentenCommunityServer 2.1 SP2 (Build: 61129.1)Windows Azure End to End Exampleshttp://sqlblog.com/blogs/buck_woody/archive/2012/05/29/windows-azure-end-to-end-examples.aspxTue, 29 May 2012 13:45:59 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:43642BuckWoody0http://sqlblog.com/blogs/buck_woody/comments/43642.aspxhttp://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=43642<p>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. </p> <p>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. </p> <p>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, <a href="http://www.microsoft.com/en-us/download/details.aspx?id=8396" target="_blank">I of course began with the Windows Azure Training Kit</a> – 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. </p> <h2>CodePlex</h2> <p><a href="http://www.codeplex.com/" target="_blank">CodePlex is Microsoft’s version of an “Open Source” repository</a>. 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. </p> <p>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 <a href="http://blobshare.codeplex.com/" target="_blank">a full project that is sort of a “Corporate Dropbox” that uses Windows Azure Storage</a>. </p> <p>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. </p> <p><strong><em>Link: <a href="http://azureexamples.codeplex.com/site/search?query=Azure&amp;ac=8">http://azureexamples.codeplex.com/site/search?query=Azure&amp;ac=8</a>&#160;</em></strong></p> <p>&#160;</p> <h2>Tailspin</h2> <p><a href="http://msdn.microsoft.com/en-us/practices/default" target="_blank">Microsoft Patterns and Practices</a> 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. </p> <p>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. </p> <p>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. </p> <p><strong><em>Link: <a href="http://msdn.microsoft.com/en-us/library/ff728592.aspx">http://msdn.microsoft.com/en-us/library/ff728592.aspx</a></em></strong></p> <h2>Azure Stock Trader</h2> <p>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.</p> <p>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. </p> <p>I use this application all the time to demonstrate Windows Azure, or a particular part of Windows Azure.</p> <p>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.&#160; </p> <p><strong><em>Links: Learn it: <a href="http://msdn.microsoft.com/en-us/netframework/bb499684">http://msdn.microsoft.com/en-us/netframework/bb499684</a> Use it: <a href="https://azurestocktrader.cloudapp.net/">https://azurestocktrader.cloudapp.net/</a></em></strong></p><img src="http://sqlblog.com/aggbug.aspx?PostID=43642" width="1" height="1">AzureCloudCloud ComputingConceptsDesignDeveloperDevelopmentDocumentationDownloadsHow I workLearningLink ListsLinksMSDNPlanningPresentationsSQL AzureTechnetTipsTutorialsWalkthroughsWebWindows AzureJava Resources for Windows Azurehttp://sqlblog.com/blogs/buck_woody/archive/2012/03/12/java-resources-for-windows-azure.aspxTue, 13 Mar 2012 00:45:00 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:42264BuckWoody2http://sqlblog.com/blogs/buck_woody/comments/42264.aspxhttp://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=42264<p>Windows Azure is a Platform as a Service &ndash; a PaaS &ndash; that runs code you write. That code doesn&rsquo;t just mean the languages on the .NET platform &ndash; you can run code from multiple languages, including Java. In fact, you can develop for Windows and SQL Azure using not only Visual Studio but the Eclipse Integrated Development Environment (IDE) as well.</p>
<p>&nbsp;Although not an exhaustive list, here are several links that deal with Java and Windows Azure:</p>
<table style="width:909px;height:1151px;" cellspacing="0" cellpadding="0">
<tr>
<td>
<p><span style="color:#ff0000;font-size:medium;"><b>Resource</b></span></p>
</td>
<td>
<p><span style="color:#ff0000;font-size:medium;"><b>Link</b></span></p>
</td>
</tr>
<tr>
<td>
<p>Windows Azure Java Development Center</p>
</td>
<td>
<p><a href="http://www.windowsazure.com/en-us/develop/java/">http://www.windowsazure.com/en-us/develop/java/</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Java Development Guidance</p>
</td>
<td>
<p><a href="http://msdn.microsoft.com/en-us/library/hh690943(VS.103).aspx">http://msdn.microsoft.com/en-us/library/hh690943(VS.103).aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Running a Java Environment on Windows Azure</p>
</td>
<td>
<p><a href="http://blogs.technet.com/b/port25/archive/2010/10/28/running-a-java-environment-on-windows-azure.aspx">http://blogs.technet.com/b/port25/archive/2010/10/28/running-a-java-environment-on-windows-azure.aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Running a Java Environment on Windows Azure</p>
</td>
<td>
<p><a href="http://blogs.technet.com/b/port25/archive/2010/10/28/running-a-java-environment-on-windows-azure.aspx">http://blogs.technet.com/b/port25/archive/2010/10/28/running-a-java-environment-on-windows-azure.aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Run Java with Jetty in Windows Azure</p>
</td>
<td>
<p><a href="http://sqlblog.com/b/dachou/archive/2010/03/21/run-java-with-jetty-in-windows-azure.aspx">http://blogs.msdn.com/b/dachou/archive/2010/03/21/run-java-with-jetty-in-windows-azure.aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Using the plugin for Eclipse</p>
</td>
<td>
<p><a href="http://sqlblog.com/b/craig/archive/2011/03/22/new-plugin-for-eclipse-to-get-java-developers-off-the-ground-with-windows-azure.aspx">http://blogs.msdn.com/b/craig/archive/2011/03/22/new-plugin-for-eclipse-to-get-java-developers-off-the-ground-with-windows-azure.aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Run Java with GlassFish in Windows Azure</p>
</td>
<td>
<p><a href="http://sqlblog.com/b/dachou/archive/2011/01/17/run-java-with-glassfish-in-windows-azure.aspx">http://blogs.msdn.com/b/dachou/archive/2011/01/17/run-java-with-glassfish-in-windows-azure.aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Improving experience for Java developers with Windows<br />&nbsp; Azure</p>
</td>
<td>
<p><a href="http://sqlblog.com/b/interoperability/archive/2011/02/23/improving-experience-for-java-developers-with-windows-azure.aspx">http://blogs.msdn.com/b/interoperability/archive/2011/02/23/improving-experience-for-java-developers-with-windows-azure.aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Java Access to SQL Azure via the JDBC Driver for SQL<br />&nbsp; Server</p>
</td>
<td>
<p><a href="http://sqlblog.com/b/brian_swan/archive/2011/03/29/java-access-to-sql-azure-via-the-jdbc-driver-for-sql-server.aspx">http://blogs.msdn.com/b/brian_swan/archive/2011/03/29/java-access-to-sql-azure-via-the-jdbc-driver-for-sql-server.aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>How to Get Started with Java, Tomcat on Windows Azure</p>
</td>
<td>
<p><a href="http://sqlblog.com/b/usisvde/archive/2011/03/04/how-to-get-started-with-java-tomcat-on-windows-azure.aspx">http://blogs.msdn.com/b/usisvde/archive/2011/03/04/how-to-get-started-with-java-tomcat-on-windows-azure.aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Deploying Java Applications in Azure</p>
</td>
<td>
<p><a href="http://sqlblog.com/b/mariok/archive/2011/01/05/deploying-java-applications-in-azure.aspx">http://blogs.msdn.com/b/mariok/archive/2011/01/05/deploying-java-applications-in-azure.aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Using the Windows Azure Storage Explorer in Eclipse</p>
</td>
<td>
<p><a href="http://sqlblog.com/b/brian_swan/archive/2011/01/11/using-the-windows-azure-storage-explorer-in-eclipse.aspx">http://blogs.msdn.com/b/brian_swan/archive/2011/01/11/using-the-windows-azure-storage-explorer-in-eclipse.aspx</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Windows Azure Tomcat Solution Accelerator</p>
</td>
<td>
<p><a href="http://archive.msdn.microsoft.com/winazuretomcat">http://archive.msdn.microsoft.com/winazuretomcat</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Deploying a Java application to Windows Azure with<br />&nbsp; Command-line Ant</p>
</td>
<td>
<p><a href="http://java.interoperabilitybridges.com/articles/deploying-a-java-application-to-windows-azure-with-command-line-ant">http://java.interoperabilitybridges.com/articles/deploying-a-java-application-to-windows-azure-with-command-line-ant</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Video: Open in the Cloud: Windows Azure and Java</p>
</td>
<td>
<p><a href="http://channel9.msdn.com/Events/PDC/PDC10/CS10">http://channel9.msdn.com/Events/PDC/PDC10/CS10</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>AzureRunMe&nbsp;</p>
</td>
<td>
<p><a href="http://azurerunme.codeplex.com/">http://azurerunme.codeplex.com/</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Windows Azure SDK for Java</p>
</td>
<td>
<p><a href="http://www.interoperabilitybridges.com/projects/windows-azure-sdk-for-java">http://www.interoperabilitybridges.com/projects/windows-azure-sdk-for-java</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>AppFabric SDK for Java</p>
</td>
<td>
<p><a href="http://www.interoperabilitybridges.com/projects/azure-java-sdk-for-net-services">http://www.interoperabilitybridges.com/projects/azure-java-sdk-for-net-services</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Information Cards for Java</p>
</td>
<td>
<p><a href="http://www.interoperabilitybridges.com/projects/information-card-for-java">http://www.interoperabilitybridges.com/projects/information-card-for-java</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Apache Stonehenge</p>
</td>
<td>
<p><a href="http://www.interoperabilitybridges.com/projects/apache-stonehenge">http://www.interoperabilitybridges.com/projects/apache-stonehenge</a><br />&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p>Channel 9 Case Study on Java and Windows Azure</p>
</td>
<td>
<p><a href="http://www.microsoft.com/casestudies/Windows-Azure/Gigaspaces/Solution-Provider-Streamlines-Java-Application-Deployment-in-the-Cloud/400000000081">http://www.microsoft.com/casestudies/Windows-Azure/Gigaspaces/Solution-Provider-Streamlines-Java-Application-Deployment-in-the-Cloud/400000000081</a><br />&nbsp;</p>
</td>
</tr>
</table>
<p>&nbsp;</p><img src="http://sqlblog.com/aggbug.aspx?PostID=42264" width="1" height="1">AzureCloudCloud ComputingComputeDevelopmentPlatform IndependenceSQL AzureWebWindows AzureTeam Foundation Server (TFS) in the Cloud - My Experience So Farhttp://sqlblog.com/blogs/buck_woody/archive/2012/01/24/team-foundation-server-tfs-in-the-cloud-my-experience-so-far.aspxTue, 24 Jan 2012 12:45:13 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:41263BuckWoody0http://sqlblog.com/blogs/buck_woody/comments/41263.aspxhttp://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=41263<p>I recently joined a software development project that involves not only myself and other internal Microsoft employees, but a partner and a customer as well. We are building a hybrid solution that uses assets on premises as well as Windows Azure for processing. When we put the team together we picked a methodology (Agile) for the project (we use multiple methodologies at Microsoft - whatever the project needs) and then we started talking about Source Control. </p> <p>We’re all comfortable with various tools for check-in-check-out, branching, and so on. We have all used GIT, SVN, and TFS. Some of us have even used Source Safe in past, but that’s another post. <img style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-79-metablogapi/6661.wlEmoticon_2D00_smile_5F00_2.png" /> Each company has a full set of Source Control systems in place. But using each other’s systems requires logins, firewalls and the like - so we decided to use the <a href="http://tfspreview.com/" target="_blank">TFS Service Preview</a> to run the entire project from “the cloud”. Here are my experiences with that. </p> <p>The process was really simple. In fact, we talked about using the cloud TFS in the first SCRUM, and the team was working from the Work Items list that afternoon. The original account login provides a web interface to allow people to join the team. Each of us happened to have a Live.Com address, so we just invited those addresses to join and they got a link, like this: </p> <p><em>projectname.tfspreview.com</em></p> <p>I’m using Visual Studio, and it’s a requirement for TFS preview to have SP1 installed, and this patch: <span style="font-family:'Calibri','sans-serif';color:#1f497d;font-size:11pt;mso-fareast-font-family:calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language:en-us;mso-fareast-language:en-us;mso-bidi-language:ar-sa;"><a href="http://go.microsoft.com/fwlink/?LinkID=212065" target="_blank"><u><font color="#0000ff">KB2581206</font></u></a></span></p> <p>From there, I opened Visual Studio and navigated from the main menu to Team and then Connect to Team Foundation Server. I’m given this menu: </p> <p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-79-metablogapi/5001.tfs_2D00_2.jpg_5F00_2.png"><img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="tfs-2.jpg" border="0" alt="tfs-2.jpg" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-79-metablogapi/1778.tfs_2D00_2.jpg_5F00_thumb.png" width="244" height="157" /></a></p> <p>Selecting port 443 and HTTPS (for security) and then ensuring the lower link has the “tfs” appended as the location, I opened the project. </p> <p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-79-metablogapi/7167.tfs_2D00_3_5F00_2.jpg"><img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="tfs-3" border="0" alt="tfs-3" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-79-metablogapi/5584.tfs_2D00_3_5F00_thumb.jpg" width="244" height="167" /></a></p> <p><em>(This VSTS screenshot is of a project I did in my University of Washington class I teach - I never show client code or names in a blog post)</em></p> <p>From there it’s a normal set of operations. Right now the preview doesn’t have some things I’d really like, such as an automated build or some of the testing tools, but <a href="http://blogs.msdn.com/b/bharry/archive/2011/09/14/team-foundation-server-on-windows-azure.aspx" target="_blank">you can read this blog entry to learn more about the entire sign-up process, and what the team has planned</a>.</p> <p>Each day I log in to the project, and I’m given this new sign-in option: </p> <p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-79-metablogapi/7635.tfs_2D00_1_5F00_2.jpg"><img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="tfs-1" border="0" alt="tfs-1" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-79-metablogapi/3438.tfs_2D00_1_5F00_thumb.jpg" width="244" height="169" /></a></p> <p>I click the option, and I open the environment, hit My Work Items query, and get to work. All in all, a seamless - although basic - experience. The speed at which we could set up and work on a project was really sweet. It’s remarkable how un-remarkable this is - I just do my work each day, everything is running and backed up in the cloud. I think that’s the point. </p><img src="http://sqlblog.com/aggbug.aspx?PostID=41263" width="1" height="1">AzureCloudCloud ComputingDeveloperDevelopmentHow I workProcessWebWindows AzurePowerShell PowerPack Downloadhttp://sqlblog.com/blogs/buck_woody/archive/2010/04/07/powershell-powerpack-download.aspxWed, 07 Apr 2010 13:30:20 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:24123BuckWoody1http://sqlblog.com/blogs/buck_woody/comments/24123.aspxhttp://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=24123<p>I read <a href="http://redmondmag.com/articles/2010/04/01/pack-some-power-in-your-shell.aspx" target="_blank">Jeffery Hicks’ article in this month’s Redmond Magazine</a> on a new add-in for Windows PowerShell 2.0. It’s called the PowerShell Pack and it has a some great new features that I plan to put into place on my production systems as soon as I finished learning and testing them.</p> <p>You can <a href="http://code.msdn.microsoft.com/PowerShellPack" target="_blank">download the pack here if you have PowerShell 2.0</a>. I’m having a lot of fun with it, and I’ll blog about what I’m learning here in the near future, but you should check it out. The only issue I have with it right now is that you have to load a module and then use get-help to find out what it does, because I haven’t found a lot of other documentation so far.</p> <p>The most interesting modules for me are the ones that can run a command elevated (in <strong>PSUserTools</strong>), the task scheduling commands (in <strong>TaskScheduler</strong>) and the file system checks and tools (in <strong>FileSystem</strong>). There’s also a way to create simple Graphical User Interface panels (in ). I plan to string all these together to install a management set of tools on my SQL Server Express Instances, giving the user “task buttons” to backup or restore a database, add or delete users and so on. Yes, I’ll be careful, and yes, I’ll make sure the user is allowed to do that.</p> <p>For now, I’m testing the download, but I thought I would share what I’m up to. If you have PowerShell 2.0 and you download the pack, let me know how you use it.</p> <p style="margin:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;" class="MsoNormal"><font face="Calibri"><b><i style="mso-bidi-font-style:normal;"><span style="color:maroon;font-size:10pt;mso-bidi-font-size:11.0pt;mso-bidi-font-family:calibri;mso-ansi-language:en;">Script Disclaimer, for people who need to be told this sort of thing: </span></i></b><b><i style="mso-bidi-font-style:normal;"><span style="color:maroon;font-size:10pt;mso-bidi-font-family:calibri;mso-ansi-language:en;"> <p></p> </span></i></b></font></p> <p style="margin:0in 0in 0pt;" class="MsoNormal"><i style="mso-bidi-font-style:normal;"><span style="color:maroon;font-size:10pt;mso-bidi-font-family:calibri;mso-ansi-language:en;"><font face="Calibri">Never trust any script, including those that you find here, until you understand exactly what it does and how it will act on your systems. Always check the script on a test system or Virtual Machine, not a production system. Yes, there are always multiple ways to do things, and this script may not work in every situation, for everything. It’s just a script, people. All scripts on this site are performed by a professional stunt driver on a closed course. Your mileage may vary. Void where prohibited. Offer good for a limited time only. Keep out of reach of small children. Do not operate heavy machinery while using this script. If you experience blurry vision, indigestion or diarrhea during the operation of this script, see a physician immediately.</font></span></i></p><img src="http://sqlblog.com/aggbug.aspx?PostID=24123" width="1" height="1">AdministrationDBADevelopmentDownloadsPowerShellSQL ServerTipsWebTools and Processes for “Fitting it all in”http://sqlblog.com/blogs/buck_woody/archive/2010/01/18/tools-and-processes-for-fitting-it-all-in.aspxMon, 18 Jan 2010 14:42:05 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:21147BuckWoody0http://sqlblog.com/blogs/buck_woody/comments/21147.aspxhttp://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=21147<p>Most data professionals I’ve met work in two modes: we plan for our day, and we react to the situations around us. I’m staring at my list of things that I need to do today right now, which is my planned work. Of course, I have no idea how much of that will really get done – it’s optimistic to be sure. On the other hand I have several systems I manage, and at any moment one of them or the people that interface with them may “change state” such that I need to give them some attention.</p> <p>So how do I meld the two? Sometimes it can be quite difficult. I’m constantly working through my list in my mind, re-arranging what I’m focusing on based on what I perceive as the highest need. There are, however, some tools that I use each day to help me manage the workflow.</p> <p>I use Outlook for tracking everything, since it has a task list (my primary tracking), a calendar, mail and so on. Also I can share the information, it’s on-line so I can see it anywhere, and I can even take it offline onto the plane this week when I fly out of town. </p> <p>For the “ad-hoc” work, I rely on a script library, which I keep as SQL Server Management Studio projects. I keep those scripts and projects backed using Microsoft Live Mesh, which synchronizes those files (along with a few other critical files and my IE Favorites) across not only my laptop and primary systems, but even with my Virtual Machines. </p> <p>Also for my SQL Server systems I use the Standard Reports I’ve blogged about here. I also use Greg Larsen’s Database Dashboard, and a series of PowerShell scripts that work across my systems, alerting me to any problems. Of course I’m using SQL Server Agent Jobs quite a bit, and I also use Alerts and some Perfmon automation for my monthly baselining.</p> <p>So – is this your experience as well? Do you get driven by both planned and unplanned work? What tools and processes do you use to keep it all straight with your SQL Server Instances?</p><img src="http://sqlblog.com/aggbug.aspx?PostID=21147" width="1" height="1">AgentDBADesignDeveloperDevelopmentManagementMicrosoftPlanningPowerShellProcessScriptsSQL ServerSQL Server Management StudioSSMSTipsWebCode that Writes Codehttp://sqlblog.com/blogs/buck_woody/archive/2009/11/25/code-that-writes-code.aspxWed, 25 Nov 2009 14:01:40 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:19171BuckWoody5http://sqlblog.com/blogs/buck_woody/comments/19171.aspxhttp://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=19171<p>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”? </p> <p>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.</p> <p>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:</p> <p>I have a table in one of my databases that I right-clicked to show the INSERT statement:</p> <font color="#008000" size="2"><font color="#008000" size="2"> <p>-- Person</p> </font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> <p>INSERT</p> </font><font color="#000000" size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">INTO</font></font><font color="#000000" size="2"> [WAVS]</font><font color="#808080" size="2"><font color="#808080" size="2">.</font></font><font color="#000000" size="2">[dbo]</font><font color="#808080" size="2"><font color="#808080" size="2">.</font></font><font size="2"><font color="#000000">[Person]</font></font></font><font size="2"><font size="2"> <p></p> </font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2"><font color="#000000">[PersonName]</font></font> <p></p> <font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">[Street]</font> <p></p> <font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">[CityStateZip]</font> <p></p> <font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2">[PersonType]</font><font color="#808080" size="2"><font color="#808080" size="2">)</font></font></font><font size="2"> <p></p> <font color="#0000ff" size="2"><font color="#0000ff" size="2">VALUES</font> <p></p> </font><font color="#808080" size="2"><font color="#808080" size="2">(&lt;</font></font><font color="#000000" size="2">PersonName</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font color="#000000" size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font color="#000000" size="2">150</font><font color="#808080" size="2"><font color="#808080" size="2">),&gt;</font></font></font><font size="2"> <p></p> <font color="#808080" size="2"><font color="#808080" size="2">,&lt;</font></font><font size="2">PersonStreet</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">100</font><font color="#808080" size="2"><font color="#808080" size="2">),&gt;</font></font></font><font size="2"> <p></p> <font color="#808080" size="2"><font color="#808080" size="2">,&lt;</font></font><font size="2">PersonCityStateZip</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">255</font><font color="#808080" size="2"><font color="#808080" size="2">),&gt;</font></font></font><font size="2"> <p></p> <font color="#808080" size="2"><font color="#808080" size="2">,&lt;</font></font><font size="2">PersonPersonType</font><font color="#808080" size="2"><font color="#808080" size="2">,</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">varchar</font></font><font color="#808080" size="2"><font color="#808080" size="2">(</font></font><font size="2">100</font><font color="#808080" size="2"><font color="#808080" size="2">),&gt;)</font></font></font> <p><font color="#808080"><font color="#808080"><font color="#333333" size="2">I can use the CTRL-SHIFT-M keys to replace the VALUES part with the values I want.&#160; </font></font></font></p> <p><font color="#808080"><font color="#808080"><font color="#333333" size="2">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 <em>Person</em> table above (note that there should only be two lines here):</font></font></font></p> <font color="#808080"><font color="#808080"><font color="#333333"><font color="#0000ff"><font color="#0000ff"> <p><font size="2">SELECT</font></p> </font><font size="2"><font color="#000000"> </font><font color="#ff0000"><font color="#ff0000">'INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES ('</font></font><font color="#000000"> </font><font color="#808080"><font color="#808080">+</font></font><font color="#000000"> </font><font color="#ff00ff"><font color="#ff00ff">CAST</font></font><font color="#808080"><font color="#808080">(</font></font><font color="#000000">[PersonID] </font><font color="#0000ff"><font color="#0000ff">AS</font></font><font color="#000000"> </font><font color="#0000ff"><font color="#0000ff">VARCHAR</font></font><font color="#808080"><font color="#808080">(</font></font><font color="#000000">5</font><font color="#808080"><font color="#808080">))+</font></font><font color="#000000"> </font><font color="#ff0000"><font color="#ff0000">', '''</font></font><font color="#000000"> </font><font color="#808080"><font color="#808080">+</font></font><font color="#000000"> [PersonName]</font><font color="#808080"><font color="#808080">+</font></font><font color="#000000"> </font><font color="#ff0000"><font color="#ff0000">''', '''</font></font><font color="#000000"> </font><font color="#808080"><font color="#808080">+</font></font><font color="#000000"> [Street]</font><font color="#808080"><font color="#808080">+</font></font><font color="#000000"> </font><font color="#ff0000"><font color="#ff0000">''', '''</font></font><font color="#000000"> </font><font color="#808080"><font color="#808080">+</font></font><font color="#000000"> [CityStateZip] </font><font color="#808080"><font color="#808080">+</font></font><font color="#000000"> </font><font color="#ff0000"><font color="#ff0000">''', '''</font></font><font color="#000000"> </font><font color="#808080"><font color="#808080">+</font></font><font color="#000000"> [PersonType] </font><font color="#808080"><font color="#808080">+</font></font><font color="#000000"> </font><font color="#ff0000"><font color="#ff0000">''')'</font></font></font></font><font color="#0000ff"><font color="#0000ff"> <p><font size="2">FROM</font></p> </font><font size="2"><font color="#000000"> [WAVS]</font><font color="#808080"><font color="#808080">.</font></font><font color="#000000">[dbo]</font><font color="#808080"><font color="#808080">.</font></font><font color="#000000">[Person]</font></font></font> <p><font color="#000000" size="2">When I run this code, I get these statements:</font></p> <p><font color="#0080c0" size="2">INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (1, 'Buck Woody', '123 Here Street', 'Covington, WA 98042', 'Vet') <br />INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (2, 'Jane Doe', '231 Function Ave', 'Redmond, WA 98052', 'Vet') <br />INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (3, 'Diane Wilson', '34251 Appt 3 7th Street', 'Seattle, WA 98061', 'Vet') <br />INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (4, 'John Kelso', '89734 Country Lane', 'Covington, WA 98042', 'Farmer') <br />INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (5, 'Marjorie Christian', '9893452 Changein Lane', 'Maple Valley, WA 98072', 'Farmer') <br />INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (6, 'Joanne Lister', '98904 Mapelwood Drive', 'Spokanne, WA 98045', 'Zoo Worker')</font></p> <p><font size="2">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).</font></p> <p><font size="2">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.</font></p> <p><font size="2">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 :)</font></p> <p><font size="2">&#160;</font></p> </font></font></font><img src="http://sqlblog.com/aggbug.aspx?PostID=19171" width="1" height="1">DBADesignDeveloperDevelopmentScriptsSQL ServerSQL Server Management StudioSSMSTipsT-SQLTutorialsVirtualizationWeb