<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.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>Benjamin Wright-Jones</title><link>http://blogs.msdn.com/b/benjones/</link><description>SQL Server Notes from the Field (Microsoft Consultancy Services)</description><dc:language>en-GB</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Using PowerShell to deploy Windows Azure Virtual Machines and Windows Azure SQL Databases</title><link>http://blogs.msdn.com/b/benjones/archive/2013/03/21/using-powershell-to-deploy-windows-azure-virtual-machines-and-windows-azure-sql-databases.aspx</link><pubDate>Thu, 21 Mar 2013 20:44:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10404335</guid><dc:creator>superlatch</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/rsscomments.aspx?WeblogPostID=10404335</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/commentapi.aspx?WeblogPostID=10404335</wfw:comment><comments>http://blogs.msdn.com/b/benjones/archive/2013/03/21/using-powershell-to-deploy-windows-azure-virtual-machines-and-windows-azure-sql-databases.aspx#comments</comments><description>&lt;p&gt;Author: Benjamin Wright-Jones (Microsoft)    &lt;br /&gt;Contributors: Karthika Raman (Microsoft)     &lt;br /&gt;Technical Reviewers: Guy Bowerman (Microsoft), Sanjay Nagamangalam (Microsoft)&lt;/p&gt;  &lt;p&gt;I have recently been exploring the use IaaS (Infrastructure as a Service) to provide cloud-based virtual machines (VM’s) as opposed to laptop-based VM’s and also PaaS (Platform as a Service) for SQL databases.&amp;#160; I like the idea of carrying around a lighter more portable laptop and using cloud services to help me day to day, in contrast to carrying a heavy weight workstation for Hyper-v usage.&lt;/p&gt;  &lt;p&gt;I know we can deploy VM’s through the Azure Portal but I prefer an automated approach.&amp;#160; Fortunately the new PowerShell cmdlets support Azure VM provisioning and also Azure SQL database provisioning (plus some other nice interfaces).&amp;#160; This enables me to quickly spin up a SQL Server VM in Azure or SQL database in Azure.&amp;#160;&amp;#160; I am actually quite amazed what is possible with PowerShell and it is my new best friend.&amp;#160; PowerShell ISE in Windows 8 is superb, I highly recommend this as a development environment due to the intellisense and cmdlets search pane integration.&amp;#160; &lt;/p&gt;  &lt;p&gt;Below is the PowerShell script I wrote to provision a VM.&amp;#160; Unfortunately some manual steps are still required if you wish to manage the SQL Server instance remotely through Management Studio e.g. opening firewall ports, enabling TCP etc.&amp;#160;&amp;#160; This is all documented here &lt;a title="http://www.windowsazure.com/en-us/manage/windows/common-tasks/sql-server-on-a-vm/" href="http://www.windowsazure.com/en-us/manage/windows/common-tasks/sql-server-on-a-vm/"&gt;http://www.windowsazure.com/en-us/manage/windows/common-tasks/sql-server-on-a-vm/&lt;/a&gt;.&amp;#160; Fortunately it is a lot easier to connect to an Azure SQL database and we can automate the registration of the provisioned instance in Management Studio. &lt;/p&gt;  &lt;h2&gt;Azure VM Provisioning (SQL Server 2012 Evaluation Edition)&lt;/h2&gt;  &lt;h5&gt;Step 1. Download and register the Azure publishing certificate (one time only event).&amp;#160; &lt;/h5&gt;  &lt;p&gt;In order to use PowerShell with the Azure VM and SQL Database services you will need to download and import the publishing file. Fortunately, this is a simple process.&amp;#160; I also store my certificate on Skydrive so I can access it everywhere I go in case I need it again. &lt;/p&gt;  &lt;pre class="csharpcode"&gt;Get-AzurePublishSettingsFile
Import-AzurePublishSettingsFile C:\...&lt;/pre&gt;


&lt;p&gt;If you don’t import the publishing file then you may see an error similar to below when attempting to access the Azure services.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;font color="#000000"&gt;An error occurred &lt;span class="kwrd"&gt;&lt;font color="#000000"&gt;while&lt;/font&gt;&lt;/span&gt; making the HTTP request to &lt;/font&gt;&lt;font color="#000000"&gt;&lt;a href="https://management.core"&gt;https:&lt;/a&gt;&lt;/font&gt;&lt;a href="https://management.core"&gt;&lt;a&gt;&lt;/a&gt;&lt;font color="#000000"&gt;&lt;a href="https://management.core"&gt;&lt;a&gt;&lt;/a&gt;&lt;span class="rem"&gt;&lt;a href="https://management.core"&gt;&lt;a&gt;&lt;font color="#000000"&gt;//&lt;/font&gt;&lt;font color="#000000"&gt;management&lt;/font&gt;&lt;/a&gt;&lt;font color="#000000"&gt;&lt;a&gt;&lt;a href="https://management.core"&gt;.core&lt;/a&gt;.&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span class="rem"&gt;&lt;font color="#000000"&gt;windows.net&lt;/font&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;font color="#000000"&gt;/ae81ecb1-a8af-4fb7-87c5-4418babb4ff2/services/sqlservers/servers&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;font color="#000000"&gt;/&amp;lt;server&amp;gt;?op=ResetPassword. &lt;/font&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;font color="#000000"&gt;This could be due to the fact that the server &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;font color="#000000"&gt;certificate is not configured properly with &lt;/font&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;font color="#000000"&gt;HTTP.SYS in the HTTPS case. This &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;font color="#000000"&gt;could also be caused by a mismatch of the security binding &lt;/font&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;font color="#000000"&gt;between the client &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="rem"&gt;&lt;font color="#000000"&gt;and the server.&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;/pre&gt;

&lt;h5&gt;Step 2. View available subscriptions and set the correct Subscription&lt;/h5&gt;

&lt;pre class="csharpcode"&gt;Get-AzureSubscription | Select SubscriptionName
Select-AzureSubscription –SubscriptionName&lt;/pre&gt;

&lt;p&gt;Incidentally, you may also need to associate a specific Azure Storage Vault (ASV) Account with your subscription, for some reason the default value was null so I had to allocate a specific account.&amp;#160; The Azure Storage account is required to host the VM disks which are provisioned during the creation of an Azure VM image.&amp;#160;&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;Get-AzureStorageAccount | Select Label
Set-AzureSubscription -SubscriptionName &lt;span class="str"&gt;&amp;quot;Windows Azure MSDN - Visual Studio Ultimate&amp;quot;&lt;/span&gt; &lt;/pre&gt;

&lt;pre class="csharpcode"&gt;-CurrentStorageAccount &lt;span class="str"&gt;&amp;quot;&amp;lt;storageaccount&amp;gt;&amp;quot;&lt;/span&gt;&lt;/pre&gt;


&lt;h5&gt;Step 3. View the available Azure VM images and locations&lt;/h5&gt;

&lt;pre class="csharpcode"&gt;Get-AzureVMImage | Select ImageName
Get-AzureLocation | Select DisplayName&lt;/pre&gt;

&lt;h5&gt;Step 4. Create an Azure VM&lt;/h5&gt;

&lt;p&gt;I like my VM’s big! ExtraLarge!&amp;#160; You can use the New-AzureQuickVM syntax, New-AzureVM or New-AzureVMConfig syntax,&amp;#160; The New-AzureQuickVM automatically creates and provisions the VM which does not require any additional steps.&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;New-AzureQuickVM -Windows -ServiceName &lt;span class="str"&gt;&amp;quot;&amp;lt;azureservice&amp;gt;&amp;quot;&lt;/span&gt; -Name &lt;span class="str"&gt;&amp;quot;&amp;lt;vmname&amp;gt;&amp;quot;&lt;/span&gt; &lt;br /&gt;-ImageName &lt;span class="str"&gt;&amp;quot;b83b3509582419d99629ce476bcb5c8__Microsoft-SQL-Server-2012-&lt;br /&gt;&lt;/span&gt;&lt;span class="str"&gt;Evaluation-CY13Feb-SQL11-SP1-CU2-11.0.3339.0&amp;quot;&lt;/span&gt; –Password &amp;lt;password&amp;gt; -Location &lt;span class="str"&gt;&amp;quot;North Europe&amp;quot; &lt;br /&gt;–InstanceSize “ExtraLarge”&lt;/span&gt;&amp;#160;&lt;/pre&gt;

&lt;p&gt;You should see something like this below.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/1447.image_5F00_2.png"&gt;&lt;img title="image" style="border-width: 0px; margin: 0px 5px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/7774.image_5F00_thumb.png" width="658" height="80" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you see a DNS error then you may be trying to provision a under a duplicate service name e.g. Error &amp;quot;DNS name already exists&amp;quot; is misleading as it refers to a duplicate service name so change this in the parameters. This servicename refers to the VM service by which you reference/connect e.g. &amp;lt;vmservice&amp;gt;.cloudapp.net&lt;/p&gt;

&lt;h5&gt;Step 6. Start the Azure VM&lt;/h5&gt;

&lt;p&gt;Start the Azure VM using the command below. &lt;/p&gt;

&lt;pre class="csharpcode"&gt;Start-AzureVM -ServiceName &lt;span class="str"&gt;&amp;quot;&amp;lt;servicename&amp;gt;&amp;quot;&lt;/span&gt; -Name &lt;span class="str"&gt;&amp;quot;&amp;lt;vmname&amp;gt;&amp;quot;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;You can view the properties of your Azure VM’s by using Get-AzureVM –ServiceName &amp;lt;ServiceName&amp;gt;.&amp;#160; I would also add that additional data disks can be simply added using the Add-AzureDataDisk syntax providing the ability to simply increase the capacity of the provisioned Azure VM instance. &lt;/p&gt;

&lt;h5&gt;Step 7. Download the&amp;#160; remote desktop connection file to your local desktop!&lt;/h5&gt;

&lt;p&gt;Another great feature is the ability to automatically download the remote desktop file for the provisioned Azure VM.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;Get-AzureRemoteDesktopFile -ServiceName &lt;span class="str"&gt;&amp;quot;&amp;lt;ServiceName&amp;gt;&amp;quot;&lt;/span&gt; -name &lt;span class="str"&gt;&amp;quot;&amp;lt;vmname&amp;gt;&amp;quot;&lt;/span&gt; -LocalPath &lt;span class="str"&gt;&amp;quot;$ENV:userprofile\Desktop\myVm01.rdp&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt; &lt;/p&gt;

&lt;p&gt;It is also possible to automatically launch and connect to your VM instance using the standard Remote Desktop client, mstsc.exe, which just eliminates another step in the process to connect to your Azure VM.&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;mstsc $ENV:userprofile\Desktop\myAzureVm1.rdp&lt;/pre&gt;


&lt;p&gt;Of course you could parameterise all of this to make life even simpler.&amp;#160; &lt;/p&gt;

&lt;h5&gt;Step 8. Connect!&lt;/h5&gt;

&lt;p&gt;Simply enter the username and password off you go, simple.&amp;#160;&amp;#160; You could create multiple PowerShell batch files for each Azure VM image type.&amp;#160; I am sticking with the SQL Server 2012 instance for now.&amp;#160; &lt;/p&gt;

&lt;h3&gt;Teardown&lt;/h3&gt;

&lt;p&gt;Cleaning up the environment is simple too, just a couple of PowerShell commands to stop and remove the provisioned VM.&lt;/p&gt;

&lt;h5&gt;Step 9. Stop the Azure VM&lt;/h5&gt;

&lt;pre class="csharpcode"&gt;Stop-AzureVM  -ServiceName &lt;span class="str"&gt;&amp;quot;&amp;lt;ServiceName&amp;gt;&amp;quot;&lt;/span&gt; -Name &lt;span class="str"&gt;&amp;quot;&amp;lt;VmName&amp;gt;&amp;quot;&lt;/span&gt;&lt;/pre&gt;


&lt;h5&gt;Step 10. Remove/delete the Azure VM&lt;/h5&gt;

&lt;pre class="csharpcode"&gt;Remove-AzureVM -ServiceName &lt;span class="str"&gt;&amp;quot;&amp;lt;ServiceName&amp;gt;&amp;quot;&lt;/span&gt; -Name &lt;span class="str"&gt;&amp;quot;&amp;lt;VmName&amp;gt;&amp;quot;&lt;/span&gt;&lt;/pre&gt;


&lt;h5&gt;Step 11. Remove/delete the Azure VM disks&lt;/h5&gt;

&lt;p&gt;The VHD’s associated with the image are not automatically removed so you will need to issue the Remove-AzureDisk command.&amp;#160; You can view the existing VHD’s and the associated image and container using the Get-AzureDisk command as shown below.&amp;#160; You will notice that I only have one disk (VHD) associated to an image.&amp;#160; The other VHD’s were from previous Azure VM deployments.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/6470.image_5F00_4.png"&gt;&lt;img title="image" style="border-width: 0px; margin: 0px 5px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/5811.image_5F00_thumb_5F00_1.png" width="697" height="148" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Removing (deleting) the VHD is simple.&amp;#160; The –DeleteVHD parameter is required if you wish to permanently delete the image from ASV so use with caution!&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Remove-AzureDisk –DiskName &amp;lt;diskname&amp;gt; –DeleteVHD&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/3731.image_5F00_6.png"&gt;&lt;img title="image" style="border-width: 0px; margin: 0px 5px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/3060.image_5F00_thumb_5F00_2.png" width="696" height="95" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;Step 12. Remove the allocated cloud service&lt;/h5&gt;

&lt;pre class="csharpcode"&gt;Remove-AzureService -ServiceName &lt;span class="str"&gt;&amp;quot;&amp;lt;servicename&amp;gt;&amp;quot;&lt;/span&gt; &lt;/pre&gt;


&lt;h5&gt;Step 13. Remember to save your PowerShell script and parameterise it for one-click deployment!&lt;/h5&gt;

&lt;h2&gt;Azure SQL Database Provisioning&lt;/h2&gt;

&lt;p&gt;On a related noted, it is also possible to provision a Windows Azure SQL Database using the new PowerShell cmdlets allowing me to rapidly deploy a cloud-based relational data store.&amp;#160; You must register the Azure publishing certificate unless this has been done previously (as above in step 1.).&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Import-AzurePublishSettingsFile C:\....
Set-AzureSqlDatabaseServer –ServerName &amp;lt;server&amp;gt; –AdminPassword &amp;lt;password&amp;gt;&lt;/pre&gt;


&lt;p&gt;Creating a new Azure SQL Database instance is also easy, an example is provided below.&amp;#160; I chose North Europe due to my geographical location.&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;New-AzureSqlDatabaseServer -location &lt;span class="str"&gt;&amp;quot;North Europe&amp;quot;&lt;/span&gt; -AdministratorLogin &lt;span class="str"&gt;&amp;quot;&amp;lt;login&amp;gt;&amp;quot;&lt;/span&gt; &lt;br /&gt;-AdministratorLoginPassword &amp;quot;&amp;lt;password&amp;gt;” &lt;/pre&gt;


&lt;p&gt;You’ll need to create a firewall rule so you can connect to the new Azure SQL Database instance:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;New-AzureSqlDatabaseServerFirewallRule -ServerName &lt;span class="str"&gt;&amp;lt;server&amp;gt;&lt;/span&gt; –RuleName &lt;font color="#006080"&gt;&amp;lt;rulename&amp;gt;&lt;/font&gt; &lt;br /&gt;-StartIPAddress &lt;span class="str"&gt;&amp;quot;0.0.0.0&amp;quot;&lt;/span&gt; -EndIPAddress &lt;span class="str"&gt;&amp;quot;222.222.222.222&amp;quot;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;As I was working through this, I discovered a VERY useful command which pops up a dialog with the help options for a specific command, an example is shown below.&amp;#160; Omitting the –ShowWindow syntax will output the help details to the console window. &lt;/p&gt;

&lt;pre class="csharpcode"&gt;Get-Help Set-AzureSqlDatabase –ShowWindow&lt;/pre&gt;


&lt;p&gt;The next step was to create a SQL Server authenticated connection to the server hosting the Windows Azure SQL Database.&amp;#160; This is an important step as it establishes the context for the connection.&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;#specify sql auth credential
$servercredential = &lt;span class="kwrd"&gt;new&lt;/span&gt;-&lt;span class="kwrd"&gt;object&lt;/span&gt; System.Management.Automation.PSCredential(&lt;span class="str"&gt;&amp;quot;&amp;lt;username&amp;gt;&amp;quot;&lt;/span&gt;, &lt;br /&gt;(&lt;span class="str"&gt;&amp;quot;&amp;lt;password&amp;gt;&amp;quot;&lt;/span&gt; | ConvertTo-SecureString -asPlainText -Force))

#create a connection context
$ctx = New-AzureSqlDatabaseServerContext –ServerName &amp;lt;servername&amp;gt; -Credential $serverCredential&lt;/pre&gt;


&lt;p&gt;Incidentally, if you are wondering what is stored in the connection context then see below:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;ServerName        : &amp;lt;server&amp;gt;
SessionActivityId : 850d5e6f-7201-4bad-8fd5-331086064d4a
ClientSessionId   : e8d82a6d-0ed2-4aa3-9c38-3c3da924ab6a-2013-03-13 15:49:35Z
ClientRequestId   : d2436b67-ecca-453d-8d7c-12619e599784-2013-03-13 16:02:36Z
Databases         : {master} &lt;/pre&gt;


&lt;p&gt;Wondering what databases you can see?&amp;#160; Easy.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Get-AzureSqlDatabase -Context $ctx&lt;/pre&gt;

&lt;p&gt;Which returns all the databases deployed on the provisioned instance.&amp;#160; In the case below, only the master database was listed as no other databases are currently deployed.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Name          : master
CollationName : SQL_Latin1_General_CP1_CI_AS
Edition       : Web
MaxSizeGB     : 5
CreationDate  : 12/03/2013 22:35:57&lt;/pre&gt;


&lt;p&gt;Want a new database?&amp;#160; Easy again.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;New-AzureSqlDatabase -Context $ctx –DatabaseName &amp;lt;databasename&amp;gt;-Collation SQL_Latin1_General_CP1_CI_AS &lt;br /&gt;-Edition Web -MaxSizeGB 5&lt;/pre&gt;

&lt;p&gt;Interestingly, there are a host of DataServiceContext class options made available under the context of the connection such as ServerMetrics and DatabaseMetrics.&amp;#160; This provides some interesting insight into the metadata for your Azure SQL database server such as throttled connections and failures.&amp;#160;&amp;#160; Unfortunately, the context commands are not documented right now so this is just exploratory and the exposed properties may be removed in the future.&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;$ctx.ServerMetrics.IncludeTotalCount()
$ctx.DatabaseMetrics.IncludeTotalCount()&lt;/pre&gt;


&lt;p&gt;Beyond the ability to provision a Windows Azure SQL Database using PowerShell cmdlets, I can also save time by automatically registering the Azure SQL instance in SQL Server Management Studio by invoking the SQL Server 2012 PowerShell command New-Item as below (thereby saving even more time!).&amp;#160; The AzureSqlDbServer1 reference is the friendly name which appears in the SQL Server Management console. &lt;/p&gt;

&lt;pre class="csharpcode"&gt;Import-Module sqlps
Cd &lt;span class="str"&gt;&amp;quot;sqlregistration\Database Engine Server Group&amp;quot;&lt;/span&gt;
New-Item AzureSqlDbServer1 -ItemType Registration -Value &lt;span class="str"&gt;&amp;quot;server=&amp;lt;server&amp;gt;.&lt;/span&gt;&lt;span class="str"&gt;database.windows.net; &lt;br /&gt;integrated &lt;/span&gt;&lt;span class="str"&gt;security=false; userid=&amp;lt;username&amp;gt;; &lt;/span&gt;&lt;span class="str"&gt;password=&amp;lt;password&amp;gt;; initial catalog=&amp;lt;databasename&amp;gt;&amp;quot;&lt;/span&gt;&lt;/pre&gt;

&lt;h3&gt;Teardown&lt;/h3&gt;

&lt;p&gt;Removing (or de-provisioning) the Azure SQL database, instance and Management Studio registration is simple.&amp;#160; The last command, Remove-Item, is a SQL Server PowerShell command to delete the Management Studio server registration and this must be invoked using sqlps as above.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Remove-AzureSqlDatabase $ctx –DatabaseName &lt;span class="str"&gt;&amp;quot;&amp;lt;dbname&amp;gt;&amp;quot;&lt;/span&gt;
Remove-AzureSqlDatabaseServer -ServerName &lt;span class="str"&gt;&amp;quot;&amp;lt;AzureSqlDbServer&amp;gt;&amp;quot;&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="str"&gt;&lt;/span&gt;Import-Module sqlps
Remove-Item AzureSqlDbServer1
&lt;/pre&gt;

&lt;h2&gt;Closing Remarks&lt;/h2&gt;

&lt;p&gt;The new PowerShell cmdlets for Azure are a fantastic way to easily provision either VM’s or a database in the cloud.&amp;#160; I will be parameterising my scripts (and including try.. catch blocks) to quickly create an Windows Azure Virtual Machine or Windows Azure SQL Database as needed (one-click deployment made easy!).&amp;#160; PowerShell ISE is also an excellent development environment which can be leveraged for not only Azure VM or SQL database provisioning but also for many more solution scenarios.&amp;#160; &lt;/p&gt;

&lt;h2&gt;What is missing?&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Provisioning Azure HDInsight clusters is not currently possible however this should be coming soon &lt;a href="http://hadoopsdk.codeplex.com"&gt;http://hadoopsdk.codeplex.com&lt;/a&gt; (refer to Programmatic Cluster Management).&amp;#160; &lt;/li&gt;

  &lt;li&gt;PowerShell cmdlets for Azure SQL Reporting are not currently available. &lt;/li&gt;

  &lt;li&gt;The ability to provision an Azure VM image with the full business intelligence stack deployed i.e. SharePoint 2013, PowerView and Power Pivot integration.&amp;#160; &lt;/li&gt;

  &lt;li&gt;PowerShell remoting to be automatically enabled in the Azure VM. &lt;/li&gt;

  &lt;li&gt;The ability to invoke SqlCmd and query Azure SQL databases through PowerShell (inc. support for Federations).&amp;#160; &lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;References&lt;/h2&gt;

&lt;p&gt;Managing Windows Azure SQL Databases with PowerShell &lt;a title="http://gallery.technet.microsoft.com/scriptcenter/Managing-Windows-Azure-SQL-632acc4b" href="http://gallery.technet.microsoft.com/scriptcenter/Managing-Windows-Azure-SQL-632acc4b"&gt;http://gallery.technet.microsoft.com/scriptcenter/Managing-Windows-Azure-SQL-632acc4b&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Windows Azure SQL Database Management with PowerShell&lt;a title="http://blogs.msdn.com/b/windowsazure/archive/2013/02/07/windows-azure-sql-database-management-with-powershell.aspx" href="http://blogs.msdn.com/b/windowsazure/archive/2013/02/07/windows-azure-sql-database-management-with-powershell.aspx"&gt;(http://blogs.msdn.com/b/windowsazure/archive/2013/02/07/windows-azure-sql-database-management-with-powershell.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Getting Started with SQL Server on a Windows Azure Virtual Machine &lt;a title="http://www.windowsazure.com/en-us/manage/windows/common-tasks/sql-server-on-a-vm/" href="http://www.windowsazure.com/en-us/manage/windows/common-tasks/sql-server-on-a-vm/"&gt;http://www.windowsazure.com/en-us/manage/windows/common-tasks/sql-server-on-a-vm/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10404335" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/benjones/archive/tags/Community/">Community</category><category domain="http://blogs.msdn.com/b/benjones/archive/tags/development/">development</category><category domain="http://blogs.msdn.com/b/benjones/archive/tags/deployment/">deployment</category></item><item><title>Building a data mart to analyse web log traffic</title><link>http://blogs.msdn.com/b/benjones/archive/2012/07/19/building-a-data-mart-to-analyse-web-log-traffic.aspx</link><pubDate>Thu, 19 Jul 2012 19:47:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10331731</guid><dc:creator>superlatch</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/rsscomments.aspx?WeblogPostID=10331731</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/commentapi.aspx?WeblogPostID=10331731</wfw:comment><comments>http://blogs.msdn.com/b/benjones/archive/2012/07/19/building-a-data-mart-to-analyse-web-log-traffic.aspx#comments</comments><description>I recently had the opportunity to build a data mart in order to analyse web logs from IIS servers.&amp;#160; The solution utilised SQL Server 2012 Database Engine, Integration Services, Analysis Services and Excel 2010 (to slice/dice the data).&amp;#160;&amp;#160;&amp;#160; &lt;p&gt;Loading IIS logs (text files with fixed width spaces) was fairly challenging due as the column definitions would alter throughout.&amp;#160; I therefore used the .NET StreamReader class to read the metadata and detect changes in the fields.&amp;#160; &lt;/p&gt;  &lt;p&gt;The data flow is shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/2678.image_5F00_55C93E26.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/6153.image_5F00_thumb_5F00_1B019550.png" width="849" height="378" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;A snippet of the code in the Load Data (Source Script Component) is presented below&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5d85c5fa-8092-4026-ad4a-0a99cacc1521" class="wlWriterEditableSmartContent" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;// Get variables&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;strSourceFile = Variables.vCurrentSourceFileName;&lt;/li&gt; &lt;li&gt;intAuditLogFileIdentifier = Variables.vAuditExecutionFileIdentifier;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;try&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008000"&gt;// Create an instance of StreamReader to read from a file.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#008000"&gt;// The using statement also closes the StreamReader.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;StreamReader&lt;/span&gt; sr = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;StreamReader&lt;/span&gt;(strSourceFile))&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#2b91af"&gt;String&lt;/span&gt; line;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; intNumberOfFields = 0; &lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;[] strListOfFields = &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#2b91af"&gt;Trace&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Log File: &amp;quot;&lt;/span&gt; + strSourceFile);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#008000"&gt;// Output the source file name as the first line (debugging purposes)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        OutputLogFileRawDataBuffer.AddRow();&lt;/li&gt; &lt;li&gt;        OutputLogFileRawDataBuffer.colRawData = strSourceFile;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#008000"&gt;// Read and display lines from the file until the end of the file is reached.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;while&lt;/span&gt; ((line = sr.ReadLine()) != &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Extracting the data from the file was relatively straightforward.&amp;#160; I placed the string into an array based on the fixed spacing between fields.&amp;#160; From the data, I was able to extract useful information such as browser type i.e. Safari, Chrome, IE and even browser version.&amp;#160; &lt;/p&gt;  &lt;p&gt;IP addresses were mapped to geolocation using the free GeoLite information &lt;a title="http://www.maxmind.com/app/geolite" href="http://www.maxmind.com/app/geolite"&gt;http://www.maxmind.com/app/geolite&lt;/a&gt; (CSV data imported into the database).&amp;#160; I converted longitude and latitude to the spatial geography data type and presented this against a world map (I wanted to validate that the GeoLite data correctly mapped to the IP address e.g. country/city to IP address). &lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;USE&lt;/span&gt; BiKitchen;&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&amp;#160;&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @SRID &lt;span class="kwrd"&gt;int&lt;/span&gt; = 4326&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @pLat nvarchar(&lt;span class="kwrd"&gt;max&lt;/span&gt;)&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @pLong nvarchar(&lt;span class="kwrd"&gt;max&lt;/span&gt;)&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @g geography&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&amp;#160;&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&lt;span class="rem"&gt;-- Check longitude and latitude for London&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;&lt;span class="kwrd"&gt;SET&lt;/span&gt; @pLat = (&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;CAST&lt;/span&gt;(Latitude &lt;span class="kwrd"&gt;AS&lt;/span&gt; nvarchar(&lt;span class="kwrd"&gt;max&lt;/span&gt;)) &lt;span class="kwrd"&gt;FROM&lt;/span&gt; [GeoData].[GeoLiteCity-Location] &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; locid = 13547)&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&lt;span class="kwrd"&gt;SET&lt;/span&gt; @pLong = (&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;CAST&lt;/span&gt;(longitude &lt;span class="kwrd"&gt;AS&lt;/span&gt; nvarchar(&lt;span class="kwrd"&gt;max&lt;/span&gt;)) &lt;span class="kwrd"&gt;FROM&lt;/span&gt; [GeoData].[GeoLiteCity-Location] &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; locid = 13547)&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;&amp;#160;&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;&lt;span class="kwrd"&gt;SET&lt;/span&gt; @g =  geography::STPointFromText(&lt;span class="str"&gt;'POINT('&lt;/span&gt; +&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        @pLong + &lt;span class="str"&gt;' '&lt;/span&gt; +&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        @pLat + &lt;span class="str"&gt;')'&lt;/span&gt;, @SRID).BufferWithTolerance(11000, 1000, 0)&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&amp;#160;&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; @pLat &lt;span class="kwrd"&gt;AS&lt;/span&gt; Latitude, @pLong &lt;span class="kwrd"&gt;AS&lt;/span&gt; Longitude&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;&lt;span class="rem"&gt;-- SELECT @g.Lat, @g.Long&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;&amp;#160;&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;&lt;span class="rem"&gt;-- Map the geography type to base world map data&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;&lt;span class="rem"&gt;-- View the result in the spatial tab to validate coordinates&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; @g &lt;span class="kwrd"&gt;AS&lt;/span&gt; spatiallocation&lt;/font&gt;&lt;/pre&gt;
  &lt;font size="1"&gt;&lt;/font&gt;

  &lt;pre&gt;&lt;font size="1"&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;&lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt; &lt;span class="kwrd"&gt;SELECT&lt;/span&gt; geog &lt;span class="kwrd"&gt;FROM&lt;/span&gt; World_Borders&lt;/font&gt;&lt;/pre&gt;
&lt;/div&gt;
&amp;#160; &lt;p&gt;The star schema was built and deployed in SQL Server 2012 Analysis Services (UDM).&amp;#160; I found named calculations to be incredibly powerful way of extending the data model and making attributes more meaningful for end-users&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/3833.image_5F00_0DBB0C3D.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/3821.image_5F00_thumb_5F00_6B8300B6.png" width="785" height="629" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The data was presented using Excel 2010, a screenshot is shown below.&amp;#160; I found slicers to be extremely useful&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/1754.image_5F00_33810CD3.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/8130.image_5F00_thumb_5F00_6CB773C8.png" width="766" height="369" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/2656.image_5F00_03964545.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/6545.image_5F00_thumb_5F00_5A3EFD46.png" width="770" height="425" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;I thought it would be interesting to see what Excel 2013 had to offer so I tried to create a Power View report but this is not currently supported against the UDM.&amp;#160;&amp;#160; There are however some nice enhancements to chart types so I’ll be looking at this in more detail. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/3005.image_5F00_7EF014BD.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/2744.image_5F00_thumb_5F00_6F6D02EE.png" width="532" height="244"&gt;&amp;#160;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10331731" width="1" height="1"&gt;</description></item><item><title>Redux: Using an SSIS package to monitor and archive the default trace file</title><link>http://blogs.msdn.com/b/benjones/archive/2012/07/05/redux-using-an-ssis-package-to-monitor-and-archive-the-default-trace-file.aspx</link><pubDate>Thu, 05 Jul 2012 05:58:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10327022</guid><dc:creator>superlatch</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/rsscomments.aspx?WeblogPostID=10327022</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/commentapi.aspx?WeblogPostID=10327022</wfw:comment><comments>http://blogs.msdn.com/b/benjones/archive/2012/07/05/redux-using-an-ssis-package-to-monitor-and-archive-the-default-trace-file.aspx#comments</comments><description>&lt;p&gt;I’ve recently been asked for details regarding the SSIS package I wrote to copy and archive the default trace file which is generated by SQL Server.&amp;#160; The contents of the file can be quite useful for troubleshooting or diagnosis purposes.&lt;/p&gt;  &lt;p&gt;I’ve updated the package to work with SQL Server 2008 R2 and SQL Server 2012.&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;The detection of a new trace file is implemented using a Script Task which watches the \Log folder for new files.&amp;#160; When a new file is detected it copies the previous file to an archive location.&amp;#160;&amp;#160; The logic is embedded in Visual Basic.NET (not my personal choice although I was limited in SQL Server 2005 when I wrote the package).&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/1376.image_5F00_16412E5B.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/8420.image_5F00_thumb_5F00_3366D665.png" width="826" height="477" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The archive process renames the file with the date and time and then copies the file to a chosen location.&amp;#160;&amp;#160; I should point out that I use expressions on a few variables to alter outputs such as the filename i.e. date_time_filename.&amp;#160; &lt;/p&gt;  &lt;p&gt;I also noticed that the service needs appropriate permissions to both access the \LOG directory and also copy to the target directory, in my scenario, this was &lt;a href="file://\\server\share"&gt;\\server\share&lt;/a&gt;.&amp;#160; When I was testing, I launch SSDT (SQL Server Data Tools) using Administrator privileges for testing purposes as a quick workround to permission issues).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/0003.image_5F00_33C2E38D.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/0728.image_5F00_thumb_5F00_0BB0346E.png" width="338" height="192" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here is the code for the Script Task (apologies for the word wrap, the Live Writer plug-in seems to do this to fit it on the page).&amp;#160; I have commented out some of the writeline commands I was using to debug the package when it was initially developed. &lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a9486f6a-ea3a-4b49-a4fe-10d30f9f5b12" class="wlWriterEditableSmartContent" style="margin: 0px; padding: 0px; float: none; display: inline;"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 3em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#008000"&gt;&amp;#39;Disclaimer: &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#008000"&gt;&amp;#39;The sample scripts and SSIS package are not supported under any Microsoft standard support program or service. &lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008000"&gt;&amp;#39;The sample scripts and SSIS package are provided AS IS without warranty of any kind. &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#008000"&gt;&amp;#39;Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. &lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008000"&gt;&amp;#39;The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#008000"&gt;&amp;#39;In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, &lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008000"&gt;&amp;#39;business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;Public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;Sub&lt;/span&gt; Main()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; vars &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Variables&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; strComputer &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;String&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; objWMIService &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;Object&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; colMonitoredEvents &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;Object&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; objEventObject &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;Object&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; strSourceDirectory &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;String&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; strServerName &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;String&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; strSourceErrorLogDirectory &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;String&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; strSourceErrorLogDirectoryWithQuotes &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;String&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;Try&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008000"&gt;&amp;#39; Use the SSIS variables in this code for the WMI query&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            strServerName = Dts.Variables(&lt;span style="color:#a31515"&gt;&amp;quot;v_ServerName&amp;quot;&lt;/span&gt;).Value&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            strSourceErrorLogDirectory = Dts.Variables(&lt;span style="color:#a31515"&gt;&amp;quot;v_DT_SourceLogDirectory&amp;quot;&lt;/span&gt;).Value&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Servername: &amp;quot;&lt;/span&gt; + strServerName)&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Monitoring &amp;#92;Log Directory: &amp;quot;&lt;/span&gt; + strSourceErrorLogDirectory)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;/li&gt; &lt;li&gt;            &lt;span style="color:#008000"&gt;&amp;#39; Replace &amp;#92; with &amp;#92;&amp;#92;&amp;#92;&amp;#92; which is needed for the WMI query&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            strSourceErrorLogDirectory = Replace(strSourceErrorLogDirectory, &lt;span style="color:#a31515"&gt;&amp;quot;&amp;#92;&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;&amp;#92;&amp;#92;&amp;#92;&amp;#92;&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;            strSourceErrorLogDirectoryWithQuotes = Chr(34) &amp;amp; strSourceErrorLogDirectory &amp;amp; Chr(34)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#008000"&gt;&amp;#39;MsgBox(&amp;quot;Server Name: &amp;quot; + strServerName)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#008000"&gt;&amp;#39; Connect to the WMI source&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            objWMIService = GetObject(&lt;span style="color:#a31515"&gt;&amp;quot;winmgmts:&amp;#92;&amp;#92;&amp;quot;&lt;/span&gt; &amp;amp; strServerName &amp;amp; &lt;span style="color:#a31515"&gt;&amp;quot;&amp;#92;root&amp;#92;cimv2&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008000"&gt;&amp;#39; Monitor the error log folder for instances of ERRORLOG.1 as this is the file we want to archive&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#008000"&gt;&amp;#39; The directory name is parameterised and populated from the SSIS variable&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#008000"&gt;&amp;#39; Monitor the directory for new default trace files&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            colMonitoredEvents = objWMIService.ExecNotificationQuery _&lt;/li&gt; &lt;li&gt;                (&lt;span style="color:#a31515"&gt;&amp;quot;SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE &amp;quot;&lt;/span&gt; _&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &amp;amp; &lt;span style="color:#a31515"&gt;&amp;quot;Targetinstance ISA &amp;#39;CIM_DirectoryContainsFile&amp;#39; and &amp;quot;&lt;/span&gt; _&lt;/li&gt; &lt;li&gt;                        &amp;amp; &lt;span style="color:#a31515"&gt;&amp;quot;TargetInstance.GroupComponent= &amp;quot;&lt;/span&gt; _&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                                &amp;amp; &lt;span style="color:#a31515"&gt;&amp;quot;&amp;#39;Win32_Directory.Name=&amp;quot;&lt;/span&gt; &amp;amp; strSourceErrorLogDirectoryWithQuotes &amp;amp; &lt;span style="color:#a31515"&gt;&amp;quot;&amp;#39;&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            objEventObject = colMonitoredEvents.NextEvent()&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008000"&gt;&amp;#39;MsgBox(&amp;quot;A new file was just created: &amp;quot; + objEventObject.TargetInstance.PartComponent)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; strReturned, strFilePath &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;String&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            strReturned = objEventObject.TargetInstance.PartComponent&lt;/li&gt; &lt;li&gt;            strFilePath = Split(strReturned, &lt;span style="color:#a31515"&gt;&amp;quot;CIM_DataFile.Name=&amp;quot;&lt;/span&gt;)(1)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            strFilePath = Replace(strFilePath, &lt;span style="color:#a31515"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;            strFilePath = Replace(strFilePath, &lt;span style="color:#a31515"&gt;&amp;quot;&amp;#92;&amp;#92;&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;&amp;#92;&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008000"&gt;&amp;#39;MsgBox(&amp;quot;Sliced file: &amp;quot; + strFilePath)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008000"&gt;&amp;#39; strFilePath is C:&amp;#92;Program Files&amp;#92;Microsoft SQL Server&amp;#92;MSSQL.1&amp;#92;MSSQL&amp;#92;LOG&amp;#92;log_nnn.trc&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#008000"&gt;&amp;#39; Array element (6) is log_nnn.trc, this assumes the above directory structure&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; strFilename &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;String&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008000"&gt;&amp;#39;strFilename = Split(strFilePath, &amp;quot;&amp;#92;&amp;quot;)(6)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#008000"&gt;&amp;#39;MsgBox(&amp;quot;Split: &amp;quot; + strFilename)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            strFilename = System.IO.&lt;span style="color:#2b91af"&gt;Path&lt;/span&gt;.GetFileName(strFilePath)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008000"&gt;&amp;#39;MsgBox(&amp;quot;IO.Path: &amp;quot; + strFilename)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008000"&gt;&amp;#39; If filename like log_ then enter this code path&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#008000"&gt;&amp;#39; The default trace filename is always log_ so we can rely on this for filename matching&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#0000ff"&gt;If&lt;/span&gt; strFilename &lt;span style="color:#0000ff"&gt;Like&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;log_*.trc&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff"&gt;Then&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;A new default trace file was just created in &amp;#92;LOG called &amp;quot;&lt;/span&gt; + strFilename)&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#2b91af"&gt;Trace&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;A new default trace file was just created in &amp;#92;LOG called &amp;quot;&lt;/span&gt; + strFilename)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#008000"&gt;&amp;#39; Archive the previous default trace file&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#008000"&gt;&amp;#39;MsgBox(&amp;quot;Default Trace found, now process the file&amp;quot;)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; arrContainer &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Array&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; intTraceFileNumber &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;Integer&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#0000ff"&gt;Dim&lt;/span&gt; strArchiveFileName &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff"&gt;String&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                arrContainer = Split(strFilename, &lt;span style="color:#a31515"&gt;&amp;quot;_&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#008000"&gt;&amp;#39;Console.WriteLine(arrContainer(0).ToString)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#008000"&gt;&amp;#39;Console.WriteLine(arrContainer(1).ToString)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#008000"&gt;&amp;#39; Split 1111.trc so we only store 1111 to convert to int&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                arrContainer = Split(arrContainer(1), &lt;span style="color:#a31515"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#008000"&gt;&amp;#39; This is the active default trace file number&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#008000"&gt;&amp;#39;Console.WriteLine(arrContainer(0).ToString)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#008000"&gt;&amp;#39; Convert the active trace file number to int and decrease by 1&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                intTraceFileNumber = &lt;span style="color:#0000ff"&gt;CInt&lt;/span&gt;(arrContainer(0)) - 1&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#008000"&gt;&amp;#39; Convert back to string and create the default trace file name&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                strArchiveFileName = &lt;span style="color:#a31515"&gt;&amp;quot;log_&amp;quot;&lt;/span&gt; + &lt;span style="color:#0000ff"&gt;CStr&lt;/span&gt;(intTraceFileNumber) + &lt;span style="color:#a31515"&gt;&amp;quot;.trc&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#008000"&gt;&amp;#39;Console.WriteLine(&amp;quot;Archiving: &amp;quot; + strArchiveFileName + &amp;quot; to &amp;quot; + Dts.Variables(&amp;quot;v_DT_DestinationDefaultTraceDirectory&amp;quot;).Value)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#008000"&gt;&amp;#39;MsgBox(strArchiveFileName)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#008000"&gt;&amp;#39;Write the filename to the SSIS variable&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                Dts.Variables(&lt;span style="color:#a31515"&gt;&amp;quot;v_DT_ActiveFileName&amp;quot;&lt;/span&gt;).Value = strArchiveFileName&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;&amp;quot;Archiving: &amp;quot;&lt;/span&gt; + strArchiveFileName + &lt;span style="color:#a31515"&gt;&amp;quot; to &amp;quot;&lt;/span&gt; + Dts.Variables(&lt;span style="color:#a31515"&gt;&amp;quot;v_DT_DestinationDefaultTraceDirectory&amp;quot;&lt;/span&gt;).Value)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                MsgBox(&lt;span style="color:#a31515"&gt;&amp;quot;Output to SSIS Variable: &amp;quot;&lt;/span&gt; + Dts.Variables(&lt;span style="color:#a31515"&gt;&amp;quot;v_DT_ActiveFileName&amp;quot;&lt;/span&gt;).Value + &lt;span style="color:#a31515"&gt;&amp;quot; strFilename: &amp;quot;&lt;/span&gt; + strArchiveFileName)&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#008000"&gt;&amp;#39; Indicate success to move on to the next step&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                Dts.TaskResult = &lt;span style="color:#2b91af"&gt;ScriptResults&lt;/span&gt;.Success&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#0000ff"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff"&gt;If&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008000"&gt;&amp;#39; Error handling&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;Catch&lt;/span&gt; ex &lt;span style="color:#0000ff"&gt;As&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(System.&lt;span style="color:#2b91af"&gt;DateTime&lt;/span&gt;.Now.ToString + &lt;span style="color:#a31515"&gt;&amp;quot; - SSIS Script Task Error: &amp;quot;&lt;/span&gt; + ex.Message.ToString)&lt;/li&gt; &lt;li&gt;            Dts.TaskResult = &lt;span style="color:#2b91af"&gt;ScriptResults&lt;/span&gt;.Failure&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff"&gt;Try&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff"&gt;Sub&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I hope you find this useful.&lt;/p&gt;  &lt;p&gt;I will try and attach the SSIS package to this post later. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10327022" width="1" height="1"&gt;</description></item><item><title>Redux: Using a C# script task in SSIS to download a file over http</title><link>http://blogs.msdn.com/b/benjones/archive/2012/07/02/redux-using-a-c-script-task-in-ssis-to-download-a-file-over-http.aspx</link><pubDate>Mon, 02 Jul 2012 21:11:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10326193</guid><dc:creator>superlatch</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/rsscomments.aspx?WeblogPostID=10326193</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/commentapi.aspx?WeblogPostID=10326193</wfw:comment><comments>http://blogs.msdn.com/b/benjones/archive/2012/07/02/redux-using-a-c-script-task-in-ssis-to-download-a-file-over-http.aspx#comments</comments><description>&lt;p&gt;A few people have asked for further information about the C# script task which I blogged about (quite a while ago).&amp;#160; I mistakenly forgot to add the full source code, sorry everyone.&amp;#160; Here is the link to the original blog post:&amp;#160; &lt;a title="http://blogs.msdn.com/b/benjones/archive/2009/03/29/using-a-c-script-task-in-ssis-to-download-a-file-over-http.aspx" href="http://blogs.msdn.com/benjones/archive/2009/03/29/using-a-c-script-task-in-ssis-to-download-a-file-over-http.aspx"&gt;http://blogs.msdn.com/benjones/archive/2009/03/29/using-a-c-script-task-in-ssis-to-download-a-file-over-http.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I have since imported the SSIS package into Visual Studio 2010 (BIDS) and the code compiles without error.&amp;#160; Some of the code below is truncated on the right (just a formatting issue I need to resolve) but the core of the code is there.&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;As always, let me know if there are any problems.&amp;#160; &lt;/p&gt;  &lt;pre class="code"&gt;&lt;font size="1"&gt;&lt;span style="color: green;"&gt;/*
   Download a file over http using Script Task in SQL Server 2008 R2 Integration Services.   &lt;br /&gt;   Two key variables, vSSOReportURL, which is constructed in a prior Script Task e.g. &lt;a href="http://www"&gt;http://www&lt;/a&gt;..&lt;br /&gt;   vSSOLocalFileName, which is the fully qualified reference for the downloaded file e.g. c:\myfile.zip&lt;/span&gt;&lt;/font&gt;&lt;font size="1"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size="1"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size="1"&gt;&lt;span style="color: green;"&gt;*/

&lt;/span&gt;&lt;span style="color: blue;"&gt;using &lt;/span&gt;System;
&lt;span style="color: blue;"&gt;using &lt;/span&gt;System.Data;
&lt;span style="color: blue;"&gt;using &lt;/span&gt;Microsoft.SqlServer.Dts.Runtime;
&lt;span style="color: blue;"&gt;using &lt;/span&gt;System.Windows.Forms;
&lt;span style="color: blue;"&gt;using &lt;/span&gt;System.Net;
&lt;span style="color: blue;"&gt;using &lt;/span&gt;System.Net.Security;

&lt;span style="color: blue;"&gt;namespace &lt;/span&gt;ST_7e897e41dd5945f3b77366d32f0a97e0.csproj
{
    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.&lt;span style="color: rgb(43, 145, 175);"&gt;SSISScriptTaskEntryPointAttribute&lt;/span&gt;]
    &lt;span style="color: blue;"&gt;public partial class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;ScriptMain &lt;/span&gt;: Microsoft.SqlServer.Dts.Tasks.ScriptTask.&lt;span style="color: rgb(43, 145, 175);"&gt;VSTARTScriptObjectModelBase
    &lt;/span&gt;{

        &lt;span style="color: blue;"&gt;#region &lt;/span&gt;VSTA generated code
        &lt;span style="color: blue;"&gt;enum &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;ScriptResults
        &lt;/span&gt;{
            Success = Microsoft.SqlServer.Dts.Runtime.&lt;span style="color: rgb(43, 145, 175);"&gt;DTSExecResult&lt;/span&gt;.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.&lt;span style="color: rgb(43, 145, 175);"&gt;DTSExecResult&lt;/span&gt;.Failure
        };
        &lt;span style="color: blue;"&gt;#endregion

 &lt;/span&gt;&lt;span style="color: green;"&gt;
        &lt;/span&gt;&lt;span style="color: blue;"&gt;public void &lt;/span&gt;Main()
        {
            &lt;span style="color: rgb(43, 145, 175);"&gt;WebClient &lt;/span&gt;myWebClient;
            &lt;span style="color: blue;"&gt;string &lt;/span&gt;RemoteURI;
            &lt;span style="color: blue;"&gt;string &lt;/span&gt;LocalFileName;
            &lt;span style="color: blue;"&gt;bool &lt;/span&gt;FireAgain = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;

            &lt;span style="color: rgb(43, 145, 175);"&gt;Variables &lt;/span&gt;vars = &lt;span style="color: blue;"&gt;null&lt;/span&gt;;
            Dts.VariableDispenser.LockForRead(&lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;User::vSSOReportURL&amp;quot;&lt;/span&gt;);
            Dts.VariableDispenser.LockForRead(&lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;User::vSSOLocalFileName&amp;quot;&lt;/span&gt;);
            Dts.VariableDispenser.LockForWrite(&lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;User::vSSOReportURLIndicator&amp;quot;&lt;/span&gt;);
            Dts.VariableDispenser.GetVariables(&lt;span style="color: blue;"&gt;ref &lt;/span&gt;vars);
             
            &lt;span style="color: blue;"&gt;try
            &lt;/span&gt;{
                &lt;span style="color: green;"&gt;// Ignore certificate warnings
                &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;ServicePointManager&lt;/span&gt;.ServerCertificateValidationCallback = 
                     &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;RemoteCertificateValidationCallback&lt;/span&gt;(&lt;span style="color: blue;"&gt;delegate &lt;/span&gt;{ &lt;span style="color: blue;"&gt;return true&lt;/span&gt;; });

                &lt;span style="color: green;"&gt;// Initiate webclient download, use default credentials (current login)
                &lt;/span&gt;myWebClient = &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;WebClient&lt;/span&gt;();
                myWebClient.Credentials = &lt;span style="color: rgb(43, 145, 175);"&gt;CredentialCache&lt;/span&gt;.DefaultCredentials; 

                RemoteURI = vars[&lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;User::vSSOReportURL&amp;quot;&lt;/span&gt;].Value.ToString();
                LocalFileName = vars[&lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;User::vSSOLocalFileName&amp;quot;&lt;/span&gt;].Value.ToString();

              &lt;span style="color: green;"&gt;
                // Log provider notification 
                &lt;/span&gt;Dts.Events.FireInformation(0, &lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Empty, &lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Format(&lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;Downloading '{0}' from '{1}'&amp;quot;&lt;/span&gt;, 
                LocalFileName, RemoteURI), &lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Empty, 0, &lt;span style="color: blue;"&gt;ref &lt;/span&gt;FireAgain);

                &lt;span style="color: green;"&gt;// Download the file 
                &lt;/span&gt;myWebClient.DownloadFile(RemoteURI, LocalFileName);

                &lt;span style="color: green;"&gt;// Set report URL indicator, this is used to determine the http source of the 
                // download i.e. vSSOReportURL or vSSOReportURLRetry for the message which is 
                // written to the table
                &lt;/span&gt;vars[&lt;span style="color: rgb(163, 21, 21);"&gt;&amp;quot;User::vSSOReportURLIndicator&amp;quot;&lt;/span&gt;].Value = 0;

                &lt;span style="color: green;"&gt;// Return success
                &lt;/span&gt;Dts.TaskResult = (&lt;span style="color: blue;"&gt;int&lt;/span&gt;)&lt;span style="color: rgb(43, 145, 175);"&gt;ScriptResults&lt;/span&gt;.Success;
            }

            &lt;span style="color: blue;"&gt;catch &lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;Exception &lt;/span&gt;ex)
            {
                &lt;span style="color: green;"&gt;// Catch and handle error 
                &lt;/span&gt;Dts.Events.FireError(0, &lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Empty, ex.Message, &lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Empty, 0);
                Dts.TaskResult = (&lt;span style="color: blue;"&gt;int&lt;/span&gt;)&lt;span style="color: rgb(43, 145, 175);"&gt;ScriptResults&lt;/span&gt;.Failure;
            }

        }


    }
}&lt;/font&gt;
&lt;/pre&gt;

&lt;p&gt;The files are extracted using an Execute Process Task (with 7-Zip) as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/7418.image_5F00_5E3A290F.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/1614.image_5F00_thumb_5F00_4B557F98.png" width="609" height="284" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the arguments are set using the expression (below).&amp;#160; There are probably better ways of doing this but I found this worked well. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/2656.image_5F00_1F285CDA.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/1665.image_5F00_thumb_5F00_18D1607F.png" width="490" height="403" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The .zip file is then archived using a File System task and the extracted file is renamed to .xlsx.&amp;#160; &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10326193" width="1" height="1"&gt;</description></item><item><title>Are you interested in Data Science?</title><link>http://blogs.msdn.com/b/benjones/archive/2012/07/02/are-you-interested-in-data-science.aspx</link><pubDate>Mon, 02 Jul 2012 14:52:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10326046</guid><dc:creator>superlatch</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/rsscomments.aspx?WeblogPostID=10326046</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/commentapi.aspx?WeblogPostID=10326046</wfw:comment><comments>http://blogs.msdn.com/b/benjones/archive/2012/07/02/are-you-interested-in-data-science.aspx#comments</comments><description>&lt;p&gt;The University of Dundee is now gauging interest in a number of data science focused courses (see below).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/0820.image_5F00_238958A1.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/5707.image_5F00_thumb_5F00_5B5B9CC4.png" width="458" height="254" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can register interest via this link &lt;a title="http://www.dundee.ac.uk/admissions/new_courses/register.php" href="http://www.dundee.ac.uk/admissions/new_courses/register.php"&gt;http://www.dundee.ac.uk/admissions/new_courses/register.php&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10326046" width="1" height="1"&gt;</description></item><item><title>Testing SQL Server HA using Hyper-V in Windows 8 Release Preview</title><link>http://blogs.msdn.com/b/benjones/archive/2012/06/21/testing-sql-server-ha-using-hyper-v-in-windows-8-release-preview.aspx</link><pubDate>Thu, 21 Jun 2012 16:22:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10322662</guid><dc:creator>superlatch</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/rsscomments.aspx?WeblogPostID=10322662</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/commentapi.aspx?WeblogPostID=10322662</wfw:comment><comments>http://blogs.msdn.com/b/benjones/archive/2012/06/21/testing-sql-server-ha-using-hyper-v-in-windows-8-release-preview.aspx#comments</comments><description>&lt;p&gt;I often find the need to build and test SQL Server clusters to support native two-node or N+1 (multi-instance) scenarios and also validate SQL Server 2012 Always On configurations.&amp;#160; I was previously running Windows Server 2008 R2 on my laptop but I a few issues using this as a day to day operating system e.g. no support for standby when hyper-v was enabled, no dual boot (hyper-v on/off) with bitlocker enabled, no Bluetooth support etc.&amp;#160; Fortunately, Windows 8 meets all my needs and the experience has been excellent to date. &lt;/p&gt;  &lt;p&gt;Note: for rapid provisioning of other images, I created a fully patched base OS image which was sysprep’d (this is incredibly easy).&amp;#160; I now just copy the image if I want to create other server roles e.g. System Center 2012. &lt;/p&gt;  &lt;p&gt;The only issue I have found to date is that host internet connectivity is affected (delayed) after defining multiple internal network adapters, therefore I switched to using Private network adapters.&amp;#160;&amp;#160; I only need internal adapters for host to guest connectivity e.g. copying files etc.&lt;/p&gt;  &lt;p&gt;My hardware and software is defined below:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Laptop HP 8540w (16GB memory, 4 cores hyper-threaded)&lt;/li&gt;    &lt;li&gt;Two internal SATA disks (hybrid) &lt;/li&gt;    &lt;li&gt;Windows 8 Release Preview (x64) with Hyper-V enabled     &lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The environment consists of the following virtual guest images:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;1 x Domain Controller (also hosts the virtual storage)&lt;/li&gt;    &lt;li&gt;1 x Primary Node (node 1)&lt;/li&gt;    &lt;li&gt;1 x Secondary Node (node 2)      &lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;All servers are running Windows Server 2008 R2 Enterprise Edition x64 with Service Pack 1.&amp;#160; The cluster role is enabled on node 1 and node 2.&amp;#160; &lt;/p&gt;  &lt;p&gt;Storage&lt;/p&gt;  &lt;p&gt;The shared storage is provisioned using the iSCSI Software Target which I defined on the domain controller.&amp;#160; I didn’t find a need to dedicate a specific storage server.&amp;#160; The screenshot of the virtual storage is presented below &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/7457.image_5F00_75B68325.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/6355.image_5F00_thumb_5F00_7A4C8DDF.png" width="620" height="184" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/3323.image_5F00_287663CD.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/3617.image_5F00_thumb_5F00_5E2BA927.png" width="615" height="488" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Cluster Validation is good, the only warning was inconsistent OS patch levels on both cluster nodes as shown below.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/7506.image_5F00_7A589FAD.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/0243.image_5F00_thumb_5F00_58209427.png" width="499" height="369" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After running cluster validation, I created a cluster and the final configuration is shown below.&amp;#160; &lt;/p&gt;  &lt;p&gt;Below is a screenshot of the raw cluster configuration.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/1526.image_5F00_21EEF60B.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/3733.image_5F00_thumb_5F00_45C7A798.png" width="663" height="449" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I’ll blog more following the SQL Server install.&amp;#160; I also plan to repeat this for Window Server 2012 and SQL Server 2012.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10322662" width="1" height="1"&gt;</description></item><item><title>Transposing Columns onto Rows</title><link>http://blogs.msdn.com/b/benjones/archive/2012/06/07/transposing-columns-onto-rows.aspx</link><pubDate>Thu, 07 Jun 2012 17:38:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10316861</guid><dc:creator>superlatch</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/rsscomments.aspx?WeblogPostID=10316861</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/commentapi.aspx?WeblogPostID=10316861</wfw:comment><comments>http://blogs.msdn.com/b/benjones/archive/2012/06/07/transposing-columns-onto-rows.aspx#comments</comments><description>&lt;p&gt;After a long period of absence, I have returned to posting some blog articles.&amp;#160; This one popped up last week from an Oracle DBA while I was onsite with a customer.&amp;#160; The conversation went something along the lines of:&lt;/p&gt;  &lt;p&gt;Oracle DBA: “How can I place columns values on rows? I have a limited page width and need to alter the output”&lt;/p&gt;  &lt;p&gt;Microsoftie “ah.. well, that’s easy..”&lt;/p&gt;  &lt;p&gt;Consider the output below:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/7245.image_5F00_03C20A3B.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/4024.image_5F00_thumb_5F00_688FD75C.png" width="345" height="107" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;but we want it to appear like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/2364.image_5F00_7D51AA0F.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/4812.image_5F00_thumb_5F00_5134AD1E.png" width="347" height="146" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The magic is really in the UNPIVOT function as shown below.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;DATABASE&lt;/span&gt; sandbox;

&lt;span class="kwrd"&gt;USE&lt;/span&gt; sandbox;

&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; tblPerson
(
    Email_Address &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(50),
    First_Name &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(50),
    Last_Name &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(50)
);

INSERT &lt;span class="kwrd"&gt;INTO&lt;/span&gt; tblPerson &lt;span class="kwrd"&gt;VALUES&lt;/span&gt;
(&lt;span class="str"&gt;'ben@test.com'&lt;/span&gt;, &lt;span class="str"&gt;'Ben'&lt;/span&gt;, &lt;span class="str"&gt;'WJ'&lt;/span&gt;)

&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; tblPerson;&lt;br /&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;   
  tblPivot.Property, tblPivot.&lt;span class="kwrd"&gt;Value&lt;/span&gt; 
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;   
  (&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;
     &lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(sql_variant,Email_Address) &lt;span class="kwrd"&gt;AS&lt;/span&gt; Email_Address,
     &lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(sql_variant,First_Name) &lt;span class="kwrd"&gt;AS&lt;/span&gt; First_Name,
     &lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(sql_variant,Last_Name) &lt;span class="kwrd"&gt;AS&lt;/span&gt; Last_Name
   &lt;span class="kwrd"&gt;FROM&lt;/span&gt; tblPerson) Person
  UNPIVOT (&lt;span class="kwrd"&gt;Value&lt;/span&gt; &lt;span class="kwrd"&gt;For&lt;/span&gt; Property &lt;span class="kwrd"&gt;In&lt;/span&gt; (Email_Address, First_Name, Last_Name)) &lt;span class="kwrd"&gt;as&lt;/span&gt; tblPivot;&lt;/pre&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10316861" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/benjones/archive/tags/SQL+Server+2008+R2/">SQL Server 2008 R2</category><category domain="http://blogs.msdn.com/b/benjones/archive/tags/development/">development</category></item><item><title>BI Service Applications in SharePoint 2010</title><link>http://blogs.msdn.com/b/benjones/archive/2011/11/29/bi-service-applications-in-sharepoint-2010.aspx</link><pubDate>Tue, 29 Nov 2011 09:29:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10242332</guid><dc:creator>superlatch</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/rsscomments.aspx?WeblogPostID=10242332</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/commentapi.aspx?WeblogPostID=10242332</wfw:comment><comments>http://blogs.msdn.com/b/benjones/archive/2011/11/29/bi-service-applications-in-sharepoint-2010.aspx#comments</comments><description>&lt;p&gt;One of my colleagues, Chris Bailiss, has written a number of great articles describing how BI service applications authenticate in SharePoint 2010.&amp;#160; If you are interested then head over here to part 1 (link below) now:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://blogs.msdn.com/b/mcsukbi/archive/2011/11/26/bi-service-applications-in-sharepoint-2010-authentication-classic-vs-claims-and-identity-delegation-kerberos-part-1.aspx" href="http://blogs.msdn.com/b/mcsukbi/archive/2011/11/26/bi-service-applications-in-sharepoint-2010-authentication-classic-vs-claims-and-identity-delegation-kerberos-part-1.aspx"&gt;http://blogs.msdn.com/b/mcsukbi/archive/2011/11/26/bi-service-applications-in-sharepoint-2010-authentication-classic-vs-claims-and-identity-delegation-kerberos-part-1.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10242332" width="1" height="1"&gt;</description></item><item><title>Two new SQLCAT papers available, Spinlock and Latch Contention</title><link>http://blogs.msdn.com/b/benjones/archive/2011/07/06/two-new-sqlcat-papers-available-spinlock-and-latch-contention.aspx</link><pubDate>Wed, 06 Jul 2011 08:21:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10183477</guid><dc:creator>superlatch</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/rsscomments.aspx?WeblogPostID=10183477</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/commentapi.aspx?WeblogPostID=10183477</wfw:comment><comments>http://blogs.msdn.com/b/benjones/archive/2011/07/06/two-new-sqlcat-papers-available-spinlock-and-latch-contention.aspx#comments</comments><description>&lt;p&gt;Diagnosing and Resolving Spinlock Contention on SQL Server&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlcat.com/whitepapers/archive/2011/07/05/diagnosing-and-resolving-spinlock-contention-on-sql-server.aspx"&gt;http://sqlcat.com/whitepapers/archive/2011/07/05/diagnosing-and-resolving-spinlock-contention-on-sql-server.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Diagnosing and Resolving Latch Contention on SQL Server&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlcat.com/whitepapers/archive/2011/07/05/diagnosing-and-resolving-latch-contention-on-sql-server.aspx"&gt;http://sqlcat.com/whitepapers/archive/2011/07/05/diagnosing-and-resolving-latch-contention-on-sql-server.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10183477" width="1" height="1"&gt;</description></item><item><title>Whitepaper Alert: Microsoft EDW Architecture, Guidance and Deployment Best Practices</title><link>http://blogs.msdn.com/b/benjones/archive/2011/05/06/whitepaper-alert-microsoft-edw-architecture-guidance-and-deployment-best-practices.aspx</link><pubDate>Fri, 06 May 2011 12:49:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10161773</guid><dc:creator>superlatch</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/rsscomments.aspx?WeblogPostID=10161773</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/benjones/commentapi.aspx?WeblogPostID=10161773</wfw:comment><comments>http://blogs.msdn.com/b/benjones/archive/2011/05/06/whitepaper-alert-microsoft-edw-architecture-guidance-and-deployment-best-practices.aspx#comments</comments><description>&lt;p&gt;&lt;a title="http://msdn.microsoft.com/en-us/library/hh147624.aspx" href="http://msdn.microsoft.com/en-us/library/hh147624.aspx"&gt;http://msdn.microsoft.com/en-us/library/hh147624.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/8306.image_5F00_2F5AE1A7.png"&gt;&lt;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="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-55-metablogapi/8780.image_5F00_thumb_5F00_22BD0EBE.png" width="530" height="107" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10161773" width="1" height="1"&gt;</description></item></channel></rss>