<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1061402500983800988</id><updated>2024-09-01T16:15:00.207-07:00</updated><title type='text'>SQLScape</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqlscape.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://sqlscape.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vishal Gamji</name><uri>http://www.blogger.com/profile/17339519129020034877</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1061402500983800988.post-5094516157306372704</id><published>2011-04-02T19:31:00.000-07:00</published><updated>2011-04-02T19:31:26.758-07:00</updated><title type='text'>The Good, The Bad and The Ugly of Metadata Management</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555;&quot;&gt;Introduction&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;The simplest definition of Metadata would be  &lt;em&gt;&#39;data that describes other data&lt;/em&gt;&#39;. It adds context, meaning and  understanding to the data being described. Database\Data warehouse projects  often have some form of metadata management associated with them. Metadata  management in simple terms would be &lt;em&gt;the continuous process of maintaining  metadata&lt;/em&gt; (adding, updating, other maintenance activities based on the form  of metadata storage). An example of metadata management would be during the data  modeling phase where the entity and attribute definitions are maintained by  tools such as Erwin, ER studio, etc. &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;For the scope of this blog I will confine  myself to the boundaries of technical metadata discussion (specifically to data  dictionary metadata).&lt;u&gt; &lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;Metadata can be broadly classified into three  types:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;1. Business Metadata: This metadata defines and  describes the actual data existing in the database or data warehouse in a  business sense. Ex: The column Quantity in table Orders refers to the total  number of orders placed by a customer in a day.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;2. Technical Metadata: This metadata stores  information about the technical aspects of the data for objects like tables,  columns, data types, data profiling, etl objects and so on. This typically is  called the data dictionary (or System Inventory).&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;An example of data dictionary metadata would be  Microsoft SQL Server’s metadata storage; SQL Server stores data about user  objects and system objects (pertaining to SQL Server) in a set of system  databases – ‘master’, ‘model’ and ‘msdb’. The master database stores data about  all the user objects (which include tables, indexes, constraints, stored  procedures, functions, views, etc.) in a set of internal system tables. Ex:  sysobjects, syscolumns, sysconstraints and other tables brilliantly exposed by  INFORMATION_SCHEMA views. Note: These system tables also store data about  themselves. &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;3. Process Execution Metadata: Data about the  actual execution of the ETL processes – like performance statistics, rows  transferred, transfer duration, errors\exceptions encountered, logging etc. In a  way 3 is also technical metadata, but I like to branch it under a separate  category due to the nature of the data.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #555555;&quot;&gt;The Why?&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;The ‘why’ of this blog is to (try to) understand  the impact of purpose &amp;amp; use of the metadata stored in the metadata  repository. Also will discuss the reasons for aligning your repository design  with the purpose of metadata. Just to be clear I myself am a big supporter of  introducing metadata in the overall architecture of a system and also to an  extent on metadata driven architectures. The buck stops at the realization point  when the effort being invested in “&lt;strong&gt;making it work&lt;/strong&gt;” is more than  the “&lt;strong&gt;actual work&lt;/strong&gt;” itself. &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;Now that we have a fairly good enough  understanding of what metadata is and its different forms of storage, lets move  on to a case of building metadata solution for a database migration  project.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;strong&gt;The (Client’s) Treasure&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Let us consider a case of designing a new enterprise data  warehouse project and also a metadata solution which is an integral part of this  effort. (I am relating this to a project that I worked on in the past where I  had approximately one thousand DB2 tables which needed a transfer to SQL Server  database at a major automobile dealership chain sharing some experience).  Situation: Create a daily load from DB2 tables into the new SQL Server data  warehouse. Assuming that our solution has the ETL part (SSIS) and also the  reporting and analysis piece (SSAS and SSRS) to it, we come up with a metadata  repository (a common sql server database) for the logging and auditing framework  for the ETL components (process metadata), a key value pair storage structure  for column definitions, ETL object definitions, report definitions, etc. (a  common structure for business and technical metadata for specific work  identified above). &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;strong&gt;The Good&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;From the descriptions of the types of metadata being stored the  purpose can be inferred as operational statistics\reporting (of scheduled jobs,  ETL processes), business definitions of columns to serve as a data dictionary  for years to come. &lt;/span&gt;&lt;/div&gt;&lt;blockquote style=&quot;font-family: Verdana,sans-serif;&quot;&gt; &lt;span style=&quot;font-size: small;&quot;&gt;&lt;em&gt;As long as the purpose and the use (at the most granular  level) is specifically understood, the pursuit towards that type of metadata  storage can be justified.&lt;/em&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Now lets assume the creation of a raw or staging area for our  warehouse where the table structures are going to be almost the same as that of  the source and given that we have the metadata of the source system (table name,  column name, data type, length, etc.) we should be able to create a similar  structure in our SQL Server warehouse environment by writing some looping  programming constructs to create all staging tables dynamically.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: small;&quot;&gt;Wow, isn&#39;t that awesome? Brag  time: I was able to create a ‘simple’ script that generated a staging area with  whopping 1000 tables plus their keys. Manually doing it is just not feasible.  Now let us compare the effort involved in creating the script\process that did  the work (less than 4 hrs.) instead of manually creating each table which if you  estimate is a lot of $$$ and not being smart (“&lt;strong&gt;making it work&lt;/strong&gt;”  vs. “&lt;strong&gt;actual work&lt;/strong&gt;”). &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;strong&gt;The &lt;em&gt;(Not so) &lt;/em&gt;Bad&lt;/strong&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;The maintenance  and constant upkeep of metadata is the ‘not so bad’. The reason being that  although it does end up taking time and effort to keep it up to date, but doing  so keeps the metadata under check. There will be the occasional exception that  will throw the metadata values out of whack an may cause your automated process  to fail. Try to fix the metadata, not the process in this case. Example: some of  the datatypes being sent by the DB2 metadata dump are mistyped as ‘datetimer’  instead of &#39;datetime’ (extra ‘r’ at the end causing the automated script to  fail). This is a very simple example. Think of other instances where you are  creating primary keys and foreign keys from the metadata. Sure, does seem like a  good idea and indeed is if the metadata is in a structured format. And yes, the  process can also be fixed or restructured to address this; but, a well defined  and well know process already exists for something like this and it is called  ‘Data Modeling’. This gets into the ‘Ugly part discussed below’.&lt;/span&gt;&lt;/div&gt;&lt;blockquote style=&quot;font-family: Verdana,sans-serif;&quot;&gt; &lt;span style=&quot;font-size: small;&quot;&gt;&lt;em&gt;Remember the purpose of the metadata store – it was just to  serve as a data dictionary in the simplest form. The ability to do something  extra out of it was a by-product.&lt;/em&gt; &lt;/span&gt;&lt;/blockquote&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;strong&gt;The (&lt;em&gt;Definitely&lt;/em&gt;) Ugly&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;The ability to script and generate the staging area was possibly  &lt;strong&gt;only&lt;/strong&gt; due to the well structured metadata from the DB2 system,  but if it were not, then the effort would be different – spending countless  number of hours to get the DB2 metadata in a “perfect” structure which could  possibly take more time than the actual work of just creating the staging area  manually one table at a time. The perfect structure would be to mimic the  storage structures which SQL Server stores its metadata in a very normalized  format that validate all the data being stored. This takes you on a quest for  finding a complex solution.&lt;/span&gt;&lt;/div&gt;&lt;blockquote style=&quot;font-family: Verdana,sans-serif;&quot;&gt; &lt;span style=&quot;font-size: small;&quot;&gt;&lt;em&gt;Your metadata repository structure does not have to be  perfect, it just needs to serve its purpose. If you end up going down the path  of making it absolutely right, then this is just over-engineering something  simple.&lt;/em&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;strong&gt;The Summary&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;Remember that your metadata does not have to be a  panacea (it is not, so try not to push too much toward making it one). Define  &lt;strong&gt;the &lt;/strong&gt;purpose of a certain piece of metadata, consider the  administration\maintenance aspect that will be spent toward it and just drive  toward achieving that purpose. There is a thin line between the bad and the  ugly. As a continuous practice keep your metadata solution the ‘good’ or the  ‘not so bad’ band and your metadata solution will have met its  purpose.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;The metadata you pursue will give you a lot of  information and every time you work with the metadata repository created  you  will get newer ideas on using it for a number of things (possibly even fueling a  rocket, watch out for such instances and prevent yourself from designing a  rocket fueling system).  &lt;/span&gt;&lt;/div&gt;&lt;blockquote style=&quot;font-family: Verdana,sans-serif;&quot;&gt; &lt;span style=&quot;color: #555555; font-size: small;&quot;&gt;&lt;em&gt;Do NOT let the the metadata implementation  &amp;amp; management overshadow the actual system implementation and your immediate  goals. &lt;/em&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;That is all I have for now. Thanks for reading.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Fun fact: The total number of time the word ‘metadata’ appears  in this article = 50 :-)&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlscape.blogspot.com/feeds/5094516157306372704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlscape.blogspot.com/2011/04/good-bad-and-ugly-of-metadata.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/5094516157306372704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/5094516157306372704'/><link rel='alternate' type='text/html' href='http://sqlscape.blogspot.com/2011/04/good-bad-and-ugly-of-metadata.html' title='The Good, The Bad and The Ugly of Metadata Management'/><author><name>Vishal Gamji</name><uri>http://www.blogger.com/profile/17339519129020034877</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1061402500983800988.post-7807780218303090099</id><published>2011-02-02T08:12:00.000-08:00</published><updated>2011-02-02T08:12:26.239-08:00</updated><title type='text'>Managing Database Code for Continuous Integration (Part 2 of 4)</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;br /&gt;
Part 2 (of 4 series) on Continuous Database Integration covers creating, managing and provisioning a database project for a continuous integration environment. I will be using Visual Studio 2010 to create a database project (.dbproj project) and for source control I will be using Subversion (open source). The usage of Visual Studio is mainly for the management of SQL scripts and (most importantly) for the deployment file that it generates, but you can do away with it and have a complete CDBI system setup in an open source environment. Most of the tools selected in this article to set up CI are free.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If your environment extensively uses Team Foundation Server (instead of Subversion), and Application Lifecycle Management (ALM), you should look into setting up continuous integration with these tools before starting to look for free ones. If you are an open source shop (two thumbs up) or want to try out standing a CI environment on your own, read on.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
This article is focused on the use of the SQL Server database project type in Visual Studio 2010. The SQL Server project type has ‘build’ and ‘deploy’ capabilities (along with a bunch of other features), which is the pivotal component of the CI setup. If you do not want to use VS 2010 Database Projects, and instead use a file system management based structure of hosting the database scripts; then, you need to manually create the re-runnable\deployable script (an OSQL or SQLCMD command script that executes all your deployable .sql scripts). Make sure you test this against a local instance of your database to emulate the build and deploy features. I created a custom C# console application that looks into specific folders (Tables, Stored Procedures etc.) and creates a command line batch script with error handling embedded in it (a custom deploy file generator was created as my project involved both oracle and sql server and I was working with Visual Studio 2005 .dbp project type), but with VS 2010 you get all these benefits plus the database testing, refactoring and it just plainly makes managing a database project much simpler (.dbproj project type). &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Difference between .dbp and .dbproj: &lt;a href=&quot;http://blogs.msdn.com/b/gertd/archive/2009/03/25/dbproj-vs-dbp.aspx&quot;&gt;http://blogs.msdn.com/b/gertd/archive/2009/03/25/dbproj-vs-dbp.aspx&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Before we begin on the CI setup of the database project, download the following tools to set up the environment:&lt;br /&gt;
1.&amp;nbsp;&amp;nbsp;&amp;nbsp; Subversion – For source control of the database project. This is by far the best and most comfortable source control system I have worked with (Sorry TFS). After installing subversion and creating a repository, make a note of the repository location as you will need it to link your database project to that.&lt;br /&gt;
2.&amp;nbsp;&amp;nbsp;&amp;nbsp; Plugin for Subversion integration with Visual studio IDE (either one of the two)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a. Visual SVN (Free to try, $49 per license)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b. Ankh SVN (Free)&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
Visual SVN vs. Ankh&lt;/b&gt;: I would recommend Visual SVN to a database centric shop that has heavy duty database development, SSIS, Reporting and\or SSAS solutions. I have had problems with Ankh SVN plugin to work correctly with these project types. It does not recognize these project types from the IDE and you end up managing them from the windows explorer instead of the commit\revert operations from the IDE. Visual SVN is much simpler to use, works perfectly with all types of project types that a database developer needs to work with. Yes, it does come with a price tag, but a license of $49 is dirt cheap. This was when I was working with Visual Studio 2005 integration. Things may have changed with Ankh since then, try it out and see what works best for your scenario. &lt;br /&gt;
&lt;br /&gt;
3.&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL Server SSMS Tools Pack: This is more of a helper plugin than a requirement. Helps you generate your seed data, save custom snippets as hotkeys, CRUD generator and more. Once you start using it you will want to get more. Download it &lt;a href=&quot;http://www.ssmstoolspack.com/&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Database Project Setup &lt;/b&gt;&lt;br /&gt;
Once the prerequisite software is installed, open Visual Studio 2010 and create a new SQL Server 2008 project.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjECP6mJ50YBGudtgRQu4ODtuVDhTaJD-XBReTVkAKhT91Q8yry03a27EvIkgb8RU710Tsunz5QupSzeBtO0uwtfiYSq2nU8XFmZEsycmL9wf_MPvDX0I1Pva44vttrt3qRL_Qrm0xDuQ/s1600/img1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;307&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjECP6mJ50YBGudtgRQu4ODtuVDhTaJD-XBReTVkAKhT91Q8yry03a27EvIkgb8RU710Tsunz5QupSzeBtO0uwtfiYSq2nU8XFmZEsycmL9wf_MPvDX0I1Pva44vttrt3qRL_Qrm0xDuQ/s400/img1.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Database Project Type&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
For demo purposes I am creating (reverse engineering by importing an existing database during project setup wizard) a database project for AdventureWorks SQL Server 2008 database [If AdventureWorks sample database is not installed on your database server, it can be downloaded from &lt;a href=&quot;http://sqlserversamples.codeplex.com/&quot;&gt;CodePlex&lt;/a&gt;]. Complete the project setup by following the necessary steps as per your database configuration. Leaving them in their default settings is also fine for the moment.&lt;br /&gt;
Once the project setup wizard completes, the solution explorer should resemble the fig. below. Right click on the project name “AdventureWorks” and select Properties to bring up the project settings. Click on the ‘Build’ option to view the location of the deployment script. Select the ‘Deploy’ tab on the left to view the deployment settings.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqG8BTUxXUQlyCiWOXh4Bnxy7N0vL7rcqJJ9l0bdPguEXFv9KbH6yqpbas0nQs23PApW9au_c9DxOktEtyICnsKQcj7wYr8xp7zQ7wMlL9D17C2QOGqyt4WMRuVI29D95qKYAEyyW8Rvg/s1600/img2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;160&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqG8BTUxXUQlyCiWOXh4Bnxy7N0vL7rcqJJ9l0bdPguEXFv9KbH6yqpbas0nQs23PApW9au_c9DxOktEtyICnsKQcj7wYr8xp7zQ7wMlL9D17C2QOGqyt4WMRuVI29D95qKYAEyyW8Rvg/s400/img2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;AdventureWorks Deployment Options&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
Now that we have the project ready, Right click the project and select ‘Build’. The status bar should go from ‘Build Started’ to ‘Build Succeeded’ status. After the Build succeeds, deploy the project by Right clicking the project and selecting ‘Deploy’. This will create a deployment script named ‘AdventureWorks.sql’ (in the Visual Studio\Projects\YourProjectFolder \sql\debug). With the database project deployment, two options are available (for now leave it in its default state: 1). &lt;br /&gt;
&lt;br /&gt;
1.&amp;nbsp;&amp;nbsp;&amp;nbsp; Create a deployment script (default)&lt;br /&gt;
2.&amp;nbsp;&amp;nbsp;&amp;nbsp; Create a deployment script and run it against a database.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVibClt5FR7a-ZWQ8kHmYSqIXTzh4iPYJ0wbqbOfbf5zHu46-seDYMfzUib9Qmq5h-XHJGUyUno4iC10wwbbPoKDPFbXhtX7dLh2JnG2WEmsnghSmvvrknF8Ml9xRuTtOjMfjGV43jUYU/s1600/img3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVibClt5FR7a-ZWQ8kHmYSqIXTzh4iPYJ0wbqbOfbf5zHu46-seDYMfzUib9Qmq5h-XHJGUyUno4iC10wwbbPoKDPFbXhtX7dLh2JnG2WEmsnghSmvvrknF8Ml9xRuTtOjMfjGV43jUYU/s320/img3.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Location of AdventureWorks.sql deployment script&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
The deployment script is the most important artifact for a successful CI system setup. This is a compilation of all the database objects belonging to your database project (including seed scripts, security etc.). After first time deployments, when a change is made to the database project, a script with the same name will be generated which will include the changes.&lt;br /&gt;
The next step is to add your project to Subversion source control. To version control your project, right click on the project and select &lt;b&gt;‘Add solution to subversion&lt;/b&gt;’. Select the repository path and add the project. And finally right click and Add files and then commit\check-in the solution. The project is now ready to be shared by anyone who has the correct setup as listed earlier.&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Preparing artifacts for CI&lt;/b&gt;&lt;br /&gt;
An isolated database instance of SQL Server needs to be provisioned for continuous build and deploy of database scripts (tear-down and reinstall). This database should not accessible to developers to use for development or testing purposes. The sole reason for the existence of this database is to test the continuous deployment of a database on either code commits or regular intervals of time. This also serves as a sanity check of your end product at any point in time. &lt;br /&gt;
Visual Studio 2010 database project provides the tear-down and install script (tear-down = recreate database) on the right click and select deploy action. But, in a continuous integration environment we would like to have this file created automatically on every build scenario. This can be implemented using the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd193283.aspx&quot;&gt;VSDBCMD&lt;/a&gt; command. You could use VSDBCMD for just creating the re-runnable deployable script (with the /dd- command line option) or use it for creating and running the deployable script (with /dd+ option at command line). If you plan to use it just for creating the re-runnable deployable script, then the script needs to be executed by either ‘sqlcmd’ or ‘OSQL’ in any environment separately.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Ideally, I would prefer using VSDBCMD just to create the deployment script and then handover the deployment script to the DBA specifying the parameters (documenting them in an implementation plan of the database). The DBAs are familiar with sqlcmd\OSQL than VSDBCMD, plus using the VSDBCMD to execute the deployment script &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd193258.aspx&quot;&gt;requires a bunch of assemblies (dll files) to be copied on the database server&lt;/a&gt;. I am not sure as to how the production DBA of today will accept this change. Thinking on the likes of a developer; sure, VSDBCMD is cool and you should definitely use in qa and production environments. But, in the real world scenario DBAs run the show. By just creating the deployable file in development and then running the same on QA and Production using sqlcmd you standardize your deployments and make your deployments simpler and worry free. (Did I mention that VSDBCMD also requires a registry change on the machine if Visual Studio is not installed on the machine, which is the database server?). &lt;br /&gt;
Not always a smooth ride; enter the obstacle: the hardcoded variables in the deployment file. &lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
Hardcoded variables in Visual Studio deployment file&lt;/b&gt;: Visual Studio deploy process creates three default parameters in the deployment file: DatabaseName, DefaultDataPath and DefaultLogPath. The ability to edit\override them is what makes the discussion of SqlCmd vs VSDBCMD interesting.&lt;br /&gt;
The main advantage with SqlCmd over VSDBCMD is the ability to pass variables as parameters to the deployment script from the command line. This is a big advantage as the VS DB project hardcodes the database name, data and log file path (mdf and ldf) in the deployment script (AdventureWorks.sql, see setvar commands below) and although there is a way to get around it, it is painful.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
:setvar &lt;span style=&quot;color: #cc0000;&quot;&gt;DatabaseName &lt;/span&gt;&quot;AdventureWorks&quot;&lt;br /&gt;
:setvar &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultDataPath &lt;/span&gt;&quot;C:\Program Files\...\DATA\&quot;&lt;br /&gt;
:setvar &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultLogPath &lt;/span&gt;&quot;C:\Program Files\...\DATA\&quot;&lt;br /&gt;
&lt;br /&gt;
Note: The above variables can be suppressed by editing the project deployment configurations. (This option can be used at runtime via command line params also).&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBtwQDk-chmMDQHU6p5msCdRGvUOKCz4bdoGM6IxKCnNLsEX6tIbGjR61Bnz5gGQq0Mj1DlGvPT7rgcmy9dB1iI-hvI6ql50Rd_FIu1I9JJXvw9XmwTlMaKQ5qNQF_mzRpWku0ZDmBUxA/s1600/img4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;27&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBtwQDk-chmMDQHU6p5msCdRGvUOKCz4bdoGM6IxKCnNLsEX6tIbGjR61Bnz5gGQq0Mj1DlGvPT7rgcmy9dB1iI-hvI6ql50Rd_FIu1I9JJXvw9XmwTlMaKQ5qNQF_mzRpWku0ZDmBUxA/s400/img4.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
At this point you have two options with sqlcmd: manually changing the &lt;span style=&quot;color: #cc0000;&quot;&gt;DatabaseName &lt;/span&gt;and &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultDataPath &lt;/span&gt;and &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultLogPath &lt;/span&gt;variables in the deployment file, or use option two i.e. changing the variables on command line with ‘SqlCmd’ using the “-v” flag for variables.&lt;br /&gt;
Ex: sqlcmd –S &lt;servername&gt; -d master -v &lt;span style=&quot;color: #cc0000;&quot;&gt;DatabaseName&lt;/span&gt;=“NewAdventureWorks” &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultDataPath&lt;/span&gt;=“C:\Data\” &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultLogPath&lt;/span&gt;=“C:\Data\”&lt;br /&gt;
&lt;br /&gt;
If you decide to go with VSDBCMD for creating the deployment file and deploying to the database server, a workaround is required to make this work. Complete the following workaround steps (skip both steps if you are going to go with sqlcmd for qa &amp;amp; production deployments):&lt;br /&gt;
1.&amp;nbsp;&amp;nbsp;&amp;nbsp; Override the DatabaseName at runtime with the TargetDatabase command line option. Ex: /p:TargetDatabase=&quot;NewAdventureWorks&quot;. This will override the :setvar &lt;span style=&quot;color: #cc0000;&quot;&gt;DatabaseName &lt;/span&gt;&quot;AdventureWorks&quot; to “NewAdventureWorks”. &lt;br /&gt;
&lt;br /&gt;
2.&amp;nbsp;&amp;nbsp;&amp;nbsp; Overriding file path variables: Let’s get something straight first – ‘The variables &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultDataPath &lt;/span&gt;and &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultLogPath &lt;/span&gt;cannot be overwritten’. Microsoft has received requests for this and is planning to allow for overwriting in the next release of database projects. For now we will have to do with a workaround. &lt;br /&gt;
&lt;br /&gt;
a. Right click on project ‘AdventureWorks’ and select ‘Deploy’. Edit the Sql command variables file by clicking the Edit button.&lt;br /&gt;
&lt;br /&gt;
&lt;/servername&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL-XjXOmDocJlU4cLPjpMt2v3EYTr84A1xMakI1Xb54SLvyUkKHTd9f4Fe2bNKK_4fGC8nIAPb3CDuj-fnwLVMieKzfYpYLrQjKGHuO_HiAulbE7L5R4bMn4URZnjMLq5hFrOqpfobsgk/s1600/img5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;107&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL-XjXOmDocJlU4cLPjpMt2v3EYTr84A1xMakI1Xb54SLvyUkKHTd9f4Fe2bNKK_4fGC8nIAPb3CDuj-fnwLVMieKzfYpYLrQjKGHuO_HiAulbE7L5R4bMn4URZnjMLq5hFrOqpfobsgk/s320/img5.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
b. Add two additional variables ‘myDataPath’ and ‘myLogPath’ as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGvXossDLWMVhucn3V_4_EGs5x4qD2FMOHwLGzMwwGGAEJN91RVDQ6DOlp0ydbqRaVbTxrflI6pXHEyDirFOyiicGnBaWVilsf2zgFvfWReJ3YwBwbEgTFspDwf7E8jQ0YmpUKSfV_ATY/s1600/img6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;49&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGvXossDLWMVhucn3V_4_EGs5x4qD2FMOHwLGzMwwGGAEJN91RVDQ6DOlp0ydbqRaVbTxrflI6pXHEyDirFOyiicGnBaWVilsf2zgFvfWReJ3YwBwbEgTFspDwf7E8jQ0YmpUKSfV_ATY/s320/img6.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
c.&amp;nbsp;&amp;nbsp;&amp;nbsp; In the database project, navigate to Schema Objects \Storage\Files and change the data file path variable in the AdventureWorks_Data.sqlfile.sql and the log file path variable in AdventureWorks_Log.sqlfile.sql to reference the newly created command variables.&lt;br /&gt;
-&amp;nbsp;&amp;nbsp;&amp;nbsp; Rename &lt;span style=&quot;color: red;&quot;&gt;$(DefaultDataPath)&lt;/span&gt; to &lt;span style=&quot;color: red;&quot;&gt;$(myDataPath)&lt;/span&gt;&lt;br /&gt;
-&amp;nbsp;&amp;nbsp;&amp;nbsp; Rename &lt;span style=&quot;color: red;&quot;&gt;$(DefaultLogPath)&lt;/span&gt; to &lt;span style=&quot;color: red;&quot;&gt;$(myLogPath)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJKySwGwiV22dsPHf8x3AENyJroWDDkxpFfzZeVUfYus_kV4ATZ4hTQF2cECvUxGxEk-HitDrzW2wSAVums33UpKpQn3f8vRwJv68TCFIf6p3Jx0uK282um3yrfN08aJ-_GnrrGLG35OY/s1600/img7.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJKySwGwiV22dsPHf8x3AENyJroWDDkxpFfzZeVUfYus_kV4ATZ4hTQF2cECvUxGxEk-HitDrzW2wSAVums33UpKpQn3f8vRwJv68TCFIf6p3Jx0uK282um3yrfN08aJ-_GnrrGLG35OY/s320/img7.jpg&quot; width=&quot;255&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
d.&amp;nbsp;&amp;nbsp;&amp;nbsp; Right click and Build the project. Navigate to .\AdventureWorks\sql\debug (location of your project) and open the AdventureWorks_Database.sqlcmdvars with Notepad. The new variables will be available to change in here.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-CLvmK13IDKYfYMT80mQlhCRJ2pDIiBa9kxMcKW6s86FQd7nINwTe5W6jSzGR-ca9AtxIAIuRal53MN7jHs1P7iOn06t9K1AKntUcx4imMn9mgKdJrWeer1_w3ez-8dgo6Iji8xy3qZ0/s1600/img8.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;98&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-CLvmK13IDKYfYMT80mQlhCRJ2pDIiBa9kxMcKW6s86FQd7nINwTe5W6jSzGR-ca9AtxIAIuRal53MN7jHs1P7iOn06t9K1AKntUcx4imMn9mgKdJrWeer1_w3ez-8dgo6Iji8xy3qZ0/s320/img8.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
As you can observe from steps 1 &amp;amp; 2 above, the workaround for using VSDBCMD can be a bit painful. One other important thing to keep in mind is that VSDBCMD does not execute pre-prepared deployment files. This is also an item that the MS team is considering to change in the next iteration. To create a deployment package VSDBCMD needs the necessary assemblies, build files, manifest, sqlcommandvars file etc. to prepare the end product (deployment file) and run it. On the other hand sqlcmd is easier to run pre-prepared deployment files (like AdventureWorks.sql). &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt; Creating the build package (build files) &amp;amp; executing the deployment output&lt;/b&gt;&lt;br /&gt;
For now, I am going to demonstrate creating the deployable file with VSDBCMD (minus steps 1 &amp;amp; 2 above) and deploying them on different environments with sqlcmd instead of using VSDBCMD.&lt;br /&gt;
&lt;br /&gt;
The workflow of the continuous builds and deployments that we are trying to emulate is:&lt;br /&gt;
a. Clear existing deployable file: In the \sql\debug folder, delete the file AdventureWorks.sql.&lt;br /&gt;
&lt;br /&gt;
b. Build the project: For now just right click and select “Build”. I will be using MSBuild to perform this task in the next article. Behind the scenes, when you right click and build, Visual Studio uses MSBuild for the build process to create the build files in \sql\debug folder.&lt;br /&gt;
&lt;br /&gt;
c. Generate deployable file AdventureWorks.sql: Using the VSDBCMD command line tool on the integration machine and the database manifest file (AdventureWorks.deploymanifest) to generate the deployment file “AdventureWorks.sql”&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt; &lt;/i&gt;Before trying out this step, make sure VSDBCMD is installed on your integration machine. &lt;br /&gt;
-&amp;nbsp;&amp;nbsp;&amp;nbsp; If Visual Studio is not already installed, then follow the instructions &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd193258.aspx&quot;&gt;here&lt;/a&gt; to download and install VSDBCMD. &lt;br /&gt;
-&amp;nbsp;&amp;nbsp;&amp;nbsp; If Visual Studio is already installed (VSDBCMD is located in “C:\Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy”), make a reference to it by adding it to your PATH variable in environment variables (instead of copying the files).&lt;br /&gt;
&lt;br /&gt;
Execute the following command in the \debug\sql folder from command prompt:&amp;nbsp; &lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
VSDBCMD /dd:- /a:Deploy /manifest: AdventureWorks.deploymanifest&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The /dd- ensures that a deployment script ‘AdventureWorks.sql’ is generated and is not executed against the database server.&lt;br /&gt;
&lt;br /&gt;
d.&amp;nbsp;&amp;nbsp;&amp;nbsp; The output of step above (AdventureWorks.sql) is executed against the integration database instance. Execute AdventureWorks.sql using ‘sqlcmd’ to test out the deployment.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Sqlcmd –S &lt;/b&gt;&lt;servername&gt;&lt;b&gt; -d &lt;/b&gt;&lt;databasename&gt;&lt;b&gt; -E –i &lt;/b&gt;&lt;file adventureworks.sql=&quot;&quot; of=&quot;&quot; path=&quot;&quot;&gt;&lt;b&gt; -o &lt;/b&gt;&lt;logfilepath&gt;&lt;b&gt; -v &lt;span style=&quot;color: #cc0000;&quot;&gt;DatabaseName&lt;/span&gt;=“&lt;/b&gt;&lt;dbname&gt;&lt;b&gt;” &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultDataPath&lt;/span&gt;=“&lt;/b&gt;&lt;datapath&gt;&lt;b&gt;” &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultLogPath&lt;/span&gt;=“&lt;/b&gt;&lt;logpath&gt;&lt;b&gt;”&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Ex: SqlCmd –S myServer -d master -E –i C:\AdventureWorks.sql -o C:\LogOutput.txt -v &lt;span style=&quot;color: #cc0000;&quot;&gt;DatabaseName&lt;/span&gt;=“NewAdventureWorks” &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultDataPath&lt;/span&gt;=“C:\Data\” &lt;span style=&quot;color: #cc0000;&quot;&gt;DefaultLogPath&lt;/span&gt;=“C:\Data\”&lt;br /&gt;
&lt;br /&gt;
Note: Variables set with –v parameters overwrite hardcoded variables set in the deployment script.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Summary&lt;/b&gt;&lt;br /&gt;
This completes our preparation of build items needed for setting up the database project for Continuous Integration. Not to worry, the steps above are for understanding the working knowledge of how the CI product (Hudson) is going to orchestrate the above steps on the server for us in the next part of this series. As far as the options go with selecting VSDBCMD for build or using it for both build and deploy, it depends on your environment. If you are flexible enough knowing the changes you have to accommodate to get VSDBCMD working in your environment, then go for it, otherwise just use it for build purposes on the build server to create the deployable product and use that going into the next environment phases (QA and Production).&lt;br /&gt;
&lt;br /&gt;
The next part of the series deals with orchestrating the steps a through d above in a repetitive manner based on either code commit\check-in or regular intervals of time. This will be set up using free tools - Hudson and NAnt. The next article will explain in detail setting up Hudson as a CI server for Database projects and configuring NAnt tasks for the actual implementation. I will also take some time to discuss a proactive vs. a reactive CI setup and how that affects development. That’s all I have for now. Thanks for reading.&lt;br /&gt;
&lt;/logpath&gt;&lt;/datapath&gt;&lt;/dbname&gt;&lt;/logfilepath&gt;&lt;/file&gt;&lt;/databasename&gt;&lt;/servername&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlscape.blogspot.com/feeds/7807780218303090099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlscape.blogspot.com/2011/02/managing-database-code-for-continuous.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/7807780218303090099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/7807780218303090099'/><link rel='alternate' type='text/html' href='http://sqlscape.blogspot.com/2011/02/managing-database-code-for-continuous.html' title='Managing Database Code for Continuous Integration (Part 2 of 4)'/><author><name>Vishal Gamji</name><uri>http://www.blogger.com/profile/17339519129020034877</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjECP6mJ50YBGudtgRQu4ODtuVDhTaJD-XBReTVkAKhT91Q8yry03a27EvIkgb8RU710Tsunz5QupSzeBtO0uwtfiYSq2nU8XFmZEsycmL9wf_MPvDX0I1Pva44vttrt3qRL_Qrm0xDuQ/s72-c/img1.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1061402500983800988.post-8659301112060912851</id><published>2010-10-06T12:30:00.000-07:00</published><updated>2011-02-02T08:18:26.391-08:00</updated><title type='text'>Agile Data warehouse Planning &amp; Implementation with Hudson, NANT, Subversion and Visual Studio Database Projects (Part 1 of 4)</title><content type='html'>&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;Overview&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;The notion of managing data warehouse projects with continuous integration with open source technologies is an uncommon practice or i guess is just unpopular in IT shops dealing with database code, SSIS and SSAS projects (from my experience). Excuses\opinions differed from company to company:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;•     “It doesn’t apply to database code projects”&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;•    “What is Continuous Integration and how does it apply to data warehouse projects?”&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;•    “Here at Acme Inc. change control is done by our architect\DBA who uses a tool called ‘AcmeErwin’ or AcmeVisio to generate code, so we don’t need the additional bells and whistles”&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;•    “Automating testing &amp;amp; deployment for database projects, SSIS packages is not possible”&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;•    “Is it worth the effort?”&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;•    “We are special, we do things differently &amp;amp; we don’t like you.” – kidding about this one.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;In this article I will try to justify the use of CI on data warehouse projects and try to address the concerns above. The subject matter of this article is geared towards planning and implementing data warehouse projects with agile development practices on the lines of iterative feature\perspective driven development.  (Perspective = Subject Area = Star Schema) The article begins with an introduction to agile development practices, reviewing &lt;a href=&quot;http://www.martinfowler.com/articles/evodb.html&quot;&gt;evolutionary database design&lt;/a&gt;, defining continuous integration in the context of database development, comparing viewpoints of waterfall and JAD methodologies to Agile, and demonstrating the coupling of the Kimball approach with Agile to establish a framework of planning long term project milestones comprised of short term visible deliverables for a data mart\warehouse project. I will do a detailed walkthrough of setting up a sample database project with the technologies (VS Database Projects for managing code, Hudson for Continuous database integration, NANT for configuring builds, subversion for source control and OSQL for executing command line SQL) is included for demonstration .&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Due to the verbose nature of my take on this, I am writing this article as a 4 part series. Trust me; the next 3 parts are going to be hands on cool stuff.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Part 1 – An introduction to agile data warehouse planning &amp;amp; development and an introduction to Continuous Database Integration (CDBI).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Part 2 – Create the database project with Visual Studio Database Projects &amp;amp; Subversion.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Part 3 – Prepare the build machine\environment with Hudson and NANT&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Part 4 – Making the medley work. Proof is in the pudding.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;Introduction&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;After shifting gears on different approaches to database development at various client sites and compiling the lessons learnt, I am close to applying a standardized methodology for the database development and management. One can apply this approach on projects regardless of size and complexity owing to its proven success.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Before starting the introduction to Continuous Integration and Agile, let me take a step back and give you a lesson learnt working with the waterfall model. While working on a new data warehouse project and adopting the waterfall SDLC approach for database project planning and implementation, over time, the implementation plan did not follow the estimated planning. Sure, it was only an estimate, but you don’t want these estimates changing forever. Here the implementation was almost always off track when compared to the initial plan. This observation was initially not visible during the initial planning phase, but over time the mismatch was more evident during the development cycle. The mismatch was due to ‘change’.  These were changes in requirements or caused due external factors. When you approach a data warehouse development methodology it is either the Kimball approach or the Inmon approach; and for my project it started off with the waterfall + Kimball. But, due to the nature of the requirements from the business where changes were too frequent, the waterfall was proving to be a showstopper. The reaction to changes and turnaround time required by the development team was slowing down the project timeline. The requirements were changing plus this project was already a mammoth effort with more than ten subject areas with conformed dimensions to form a data mart.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;The old school approach on starting a new database project (with the waterfall cycle) begins with initial requirements and then comes in the logical model and then the physical model. Usually In this approach you have an ‘architect’ or a ‘data modeler’ or an application DBA on the project who owns the schema and is responsible for making changes from inception to maturity. This methodology is almost perfect and everyone starts posting those ER diagrams on their walls and showing off, until Wham! Requirements start changing and for every change you need to go back, change the specification, the schema and then the actual code behind, and of course the time for testing. As the frequency of these changes goes up, this catapults the delivery dates and changes your project plan. In this approach, the turnaround time for delivering an end product with the changes identified is just not feasible. I am not debating that using a waterfall approach will determine success or failure; I am trying to juxtapose the effort involved (basically showing you the time spent in the spiral turnover of the waterfall model then will compare it with an agile approach). This is a classic example of how the traditional waterfall approach hinders the planning and implementation of your project.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;This called for a need for a change in the development approach, one that could react quickly to any change that could affect the time-line of deliverables.  The new approach adopted was an agile development practice + the Kimball method which resulted in a successful implantation of a large scale data mart for a health care company&lt;/span&gt;&lt;/span&gt;. &lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span&gt;By now you should have an idea on what I am trying to sell here.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;What is Continuous Integration?&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Continuous Integration is all about automating the activities involved in releasing a feature\component of software and be able to simulate the process in a repeatable manner to reduce manual intervention and thus improving quality of the product being built. This set of repeatable steps typically involves running builds (compiling source code), unit testing, integration testing, static code analysis, deploying code, analyzing code metrics (quality of code, frequency of errors) etc.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Continuous Integration for database development is the ability to build a database project (a set of files that make up your database) in a repeatable manner such that the repeatable action mimics the deployment of your database code. Depending on the database development structure database projects can successfully be set up to run scheduled builds, automate unit testing, start jobs and deploy code to different environments or stage it for deployment to reduce human error that a continuous and monotonous process can bring.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The CDBI (Continuous Database Integration) Environment&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;The best part about the tools I am going to set up the continuous integration environment is that they are all FREE. Almost all are free except Visual Studio Team Edition for Database Professionals. I would highly recommend using VS Team Edition for Database Professionals as a tool for developing and managing code when working with database projects. The others tools that I used for continuous integration is Hudson, Subversion and NANT. Yes, freeware used mostly by the othe other community. But  after applying them side by side with MS technologies, that proved to be a good mix. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;All of the above opinions when drilled down, point to the concept of ‘done’ or to ‘a deliverable’.  The granularity of the deliverable is pivotal to incremental software development.  It is just a matter of perspective – for incremental software development the granularity of your deliverable is much smaller and the visibility is much clear and concise when compared to a deliverable on the waterfall track. On the continuous sprints you know for sure what needs to be delivered by the next sprint\iteration. At this point you have a definition of ‘done’. This is the most important thing when we start getting into agile development practices – The concept of done. [TechEd Thanks]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;The more tasks are granular, easier they become to control and complete. Once you start slacking on a few, they then to pile up and that happens on a larger scale, they fog the plan even worse. Once you step in to the shoes of a project planner and also of a lead, this gap will become more evident and clear.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;    This is where CI helps in meeting deadlines, showing progress of work in regular sprints where the previous sprint progress is evaluated (to validate the concept of done) and requirement for the next sprint is defined.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Summary&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;To summarize, Continuous Integration in a DB environment is all about developing your database code in sprints (of two weeks or more, your choice), by a feature or perspective. Ex: A feature in the AdventureWorks database would be HR module or the Sales module. An example in a data warehouse environment could be the Inventory star schema. It is these short sprints (regular intervals of feature completion or deliverable, usually 2 weeks) of clear quantifiable requirements (definition of ‘done’) that helps gauge the status of work. Once the developers adapt to this rapid SDLC, visibility into the progress of the work goes up, results in accountability and ownership of work, building a more cohesive team and increased productivity (I can bet on this one) and most important of all, a quality product being delivered in chunks to form the big picture. The big picture being a collection of perspectives(start schemas) that plug together to form a data warehouse. That is all I have for now, more to follow in my part 2, 3 and 4 on setting up the CI environment with a database project, using Subversion as source control system and NANT for creating build files.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Thanks for reading &amp;amp; stay tuned ….&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size:100%;&quot;&gt;Vishal Gamji&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlscape.blogspot.com/feeds/8659301112060912851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlscape.blogspot.com/2010/10/agile-data-warehouse-planning.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/8659301112060912851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/8659301112060912851'/><link rel='alternate' type='text/html' href='http://sqlscape.blogspot.com/2010/10/agile-data-warehouse-planning.html' title='Agile Data warehouse Planning &amp; Implementation with Hudson, NANT, Subversion and Visual Studio Database Projects (Part 1 of 4)'/><author><name>Vishal Gamji</name><uri>http://www.blogger.com/profile/17339519129020034877</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1061402500983800988.post-7884483115270767159</id><published>2010-06-29T01:31:00.000-07:00</published><updated>2010-06-29T03:54:09.179-07:00</updated><title type='text'>Deploying SSIS Packages with XML Configurations</title><content type='html'>&lt;div&gt;SSIS trivia: What do admins detest most about SSIS deployment?&lt;br /&gt;Answer: The Environment Variable configuration.&lt;br /&gt;One the features included by Microsoft for flexibility &amp;amp; ease of deployment between environments. If your answer was registry files, you were close. Environment Variables is on top (Registry Files comes in second). &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;The Nutshell Overview&lt;/strong&gt;&lt;/em&gt;: This article is all about using XML configurations in SSIS, direct vs. indirect configurations, pros and cons and explaining the deployment issues and concerns with these types of configurations. For the purpose of this article, when relating to database connection strings I am assuming that AD authentication is used all over. SQL authentication is out of scope, for now (otherwise I will have geeks rioting). This article is also me doing some ground work for my next article. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;XML Configurations&lt;/em&gt;&lt;/strong&gt;: XML configurations in SSIS can be used in one of two ways&lt;br /&gt;1. Direct Configuration: This configuration setting takes the form of a hardcoded path in the package itself and changing this between different environments when moving packages to QA or Production; it is the responsibility of the deployer to rely on the manifest (explained below) or changing the dtsx manually. When this type of configuration is used, it becomes a mandate that the path of the XML Configuration file is going to remain the same for all developers (on their machines) working on the project.&lt;br /&gt;For example the path of the XML config is C:\myXMLConfig.dtsconfig for say 10 packages in a solution. Now, when another developer joins the merry band, the new developer has to ensure that the configuration file used is in the same path set by the previous developer. If the new developer places his configuration file in a different location, say something like “D:\myXMLConfig.dtsconfig”, then the previous developer’s development environment will not load correctly (Assuming both developers are working on gold code and checking out and committing to the same source repository).&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikSUfy5WTN6NqgrWYsdL1oQeaWlEz2oavH9HKV9gTi31TFj6-mI-iG4asZpW_G4AQfBuIKOYDOpPfl1vzJXdUJoSVg4NSeXorB2j7m1uuWUMRix1AneJKMQr7SZ_Wh2lZSgFkxXgOdqvs/s1600/DirectXMLConfig.jpg&quot;&gt;&lt;img style=&quot;TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 291px; CURSOR: hand&quot; id=&quot;BLOGGER_PHOTO_ID_5488115211491265938&quot; border=&quot;0&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikSUfy5WTN6NqgrWYsdL1oQeaWlEz2oavH9HKV9gTi31TFj6-mI-iG4asZpW_G4AQfBuIKOYDOpPfl1vzJXdUJoSVg4NSeXorB2j7m1uuWUMRix1AneJKMQr7SZ_Wh2lZSgFkxXgOdqvs/s320/DirectXMLConfig.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Fig 1: Direct XML Configuration&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;The SSIS Manifest&lt;/em&gt;&lt;/strong&gt;:&lt;br /&gt;The SSIS Manifest file is a setup file, similar to the Installers that you run for software products which on the click of the next-next-finish complete your software installation. The manifest file when opened launches a wizard where you can specify the new location for the configuration and change configurations and also the new location of the packages when deploying to different environments. From what I understood from the working of the manifest; it basically does two important tasks (please comment if I missed any):&lt;br /&gt;&lt;br /&gt;a. Copying the SSIS packages between environments (Same as using XCOPY or DTUtil. Bet DTUtil uses XCOPY behind the scenes)&lt;br /&gt;&lt;br /&gt;b. Change the XML configuration file path (a simple Find-Replace based on the XML node find on Configuration Type =5 or 1. Open the SSIS package in a text editor to view the SSIS package XML code for configuration types)&lt;br /&gt;&lt;br /&gt;i. ConfigurationType =5: Indirect Configuration (described below)&lt;br /&gt;ii. ConfigurationType =1: Direct (hard-coded) XML file path configuration.&lt;br /&gt;&lt;br /&gt;2. Indirect configuration: Indirect configurations in SSIS packages allow you to reference a configuration file to a virtual name i.e. to an environment variable. This means that the SSIS configuration value that is embedded in the package(s) is an environment variable (key\name), the value of which is the actual path of the XML configuration file. When this kind of a setting is used for configurations, during deployment time, only the environment variable need to be added to the environments where the packages are deployed.&lt;br /&gt;&lt;div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXdbv7-W053XFqx981DYMnp0P1NkPpkQOZkTOyIiHMcyPBBJMi_dkfx7KloWN9hXsTvGL11GJE0XFHfoJAtVLl4oHYruS8ZREYdLNzzQRT3Nm2FmW-7liM2MQnwnCqfkqqCCOmfkV_2Fw/s1600/IndirectXMLConfig.jpg&quot;&gt;&lt;img style=&quot;TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 294px; CURSOR: hand&quot; id=&quot;BLOGGER_PHOTO_ID_5488115220501482002&quot; border=&quot;0&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXdbv7-W053XFqx981DYMnp0P1NkPpkQOZkTOyIiHMcyPBBJMi_dkfx7KloWN9hXsTvGL11GJE0XFHfoJAtVLl4oHYruS8ZREYdLNzzQRT3Nm2FmW-7liM2MQnwnCqfkqqCCOmfkV_2Fw/s320/IndirectXMLConfig.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Fig 2.1: Indirect XML Configuration&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpIv_NBRQAr3ix6vZwVRdW9kV2nD4IQWgOA1BhEiBt_2EH5mXBAP5mZIKRYnlL_9gcbKfrrbhLkKvgvpHjdf4t6BTxc6Kb7OVxQFCM0wXyag2TepcgsQAoqpeEpMcfM9JKFjf6hGO4Um0/s1600/EnvVariable.jpg&quot;&gt;&lt;img style=&quot;TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 136px; CURSOR: hand&quot; id=&quot;BLOGGER_PHOTO_ID_5488115235392640546&quot; border=&quot;0&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpIv_NBRQAr3ix6vZwVRdW9kV2nD4IQWgOA1BhEiBt_2EH5mXBAP5mZIKRYnlL_9gcbKfrrbhLkKvgvpHjdf4t6BTxc6Kb7OVxQFCM0wXyag2TepcgsQAoqpeEpMcfM9JKFjf6hGO4Um0/s320/EnvVariable.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Fig 2.2: Environment variable configuration&lt;br /&gt;&lt;br /&gt;There are issues where implementing this type of configuration setting in some environments. Two main issues:&lt;br /&gt;&lt;br /&gt;a. Machine reboot on environment variable add\modify: When an environment variable is added, in order for it to take effect, i.e. in order for the packages to start recognizing it, the machine needs to be restarted. This is not true. Same holds true when modifying the environment variable. There have been numerous questions and concerns on this topic and since an obvious panic button is hit with the word ‘reboot’, people tend to stay away from this setting. The reality check is that the process which is running the SSIS packages needs a restart. Typically this is the SQL agent, which is the scheduler for the packages. In a development environment the BIDS needs a restart. This is one of the most important concerns a DBA has with SSIS configuration.&lt;br /&gt;&lt;br /&gt;b. Development &amp;amp; QA on same server: This issue crops up when DBAs provision development and QA instances of SQL Server on the same machine. In such environments it becomes impossible to implement indirect configuration settings with environment variables as one environment variable cannot be used for both environments development and QA.&lt;br /&gt;&lt;br /&gt;Other than the obstacle (b) above, the environment variable coupled with XML configurations is the simplest and most flexible way of deploying SSIS packages between environments (again, going back to the assumption of AD authentication). I have gone down the path of trying to think of different ways of convincing the admins for implementing environment variables at various companies; in some cases I was able to sell my pain, in other cases had to walk away with explanations on the ‘complexity’ of ‘maintaining’ environment variables and it was back to the drawing board to find another solution.&lt;br /&gt;&lt;br /&gt;As a developer, I may not be totally in tune with the ‘complexity’, ‘security breaches’ and the ‘challenges’ (stress on quotes) involved in maintaining environment variables, but really?, after all the security ‘gizmos’ an organization has in place to stop Intrusions, inc. one would really ponder on the need for an overdose of security, but, such is life … and I don’t blame the admins for doing their job (maybe I would have done the same thing if I were a production DBA). DBAs would want to minimize the loopholes, build better security practices and keep the servers clean of environment variables and registry files; and on the other hand a smart developer wants to incorporate similar best practices, coding standards, ease of deployments between environments, etc. and truly it is difficult to see green on both sides of the fence.&lt;br /&gt;&lt;br /&gt;In the domain of deployment of packages between environments; the MS Integration Services team did a good job making the XML configurations, database configurations etc. available to us in SSIS, using which the migration of code between development, QA and production has become simple and efficient. Along those lines, they have given us the (risky) capability of saving sensitive information as clear text in XML configurations. They do have a neat way of letting us save the sensitive information and we take the risk of saving such information, i.e. the packages themselves strip the passwords and anything marked sensitive. This goes back to deployment modes msdb and file system which I will not delve into.&lt;br /&gt;&lt;br /&gt;If one would think of SSIS configurations as a bane; try implementing continuous integration and deployment of SSIS projects\packages without configurations, and trust me; if you have not already, you will feel the pain (been there, felt that).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Summary&lt;/em&gt;&lt;/strong&gt;: &lt;br /&gt;At the end it comes to selling your pain in that meeting room with quasi-knowledgeable management, the so called technical managers and DBAs over security &amp;amp;maintainability vs. flexibility &amp;amp; ease of implementation. You know which scale weighs heavier, don’t you? It’s the DBA side of the scale, i.e. the security part of it. But, you don’t see me frowning, coz someone once told me “A problem\setback is an opportunity in disguise” (or something like that). In my next article I will demonstrate how I really did find opportunity in this obstacle (hint: has something to do with continuous integration with SSIS &amp;amp; C# and the next paragraph).&lt;br /&gt;&lt;br /&gt;Personally, i like the database configurations and in my implementations of SSIS projects. I give it a mix of XML configuration (The road less travelled: indirect in development environment, convert it to direct in QA &amp;amp; Production.) and database configuration elements to it. This keeps the deployers\admins at bay and gives me more power as a developer to enforce configurations at the database level for my application.&lt;br /&gt;More about the road less travelled in my next article.&lt;br /&gt;Sometimes I wonder if I should start another blog - SqlDeveloperRants.blogspot.com.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlscape.blogspot.com/feeds/7884483115270767159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlscape.blogspot.com/2010/06/deploying-ssis-packages-with-xml.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/7884483115270767159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/7884483115270767159'/><link rel='alternate' type='text/html' href='http://sqlscape.blogspot.com/2010/06/deploying-ssis-packages-with-xml.html' title='Deploying SSIS Packages with XML Configurations'/><author><name>Vishal Gamji</name><uri>http://www.blogger.com/profile/17339519129020034877</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikSUfy5WTN6NqgrWYsdL1oQeaWlEz2oavH9HKV9gTi31TFj6-mI-iG4asZpW_G4AQfBuIKOYDOpPfl1vzJXdUJoSVg4NSeXorB2j7m1uuWUMRix1AneJKMQr7SZ_Wh2lZSgFkxXgOdqvs/s72-c/DirectXMLConfig.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1061402500983800988.post-774889483522449666</id><published>2009-04-15T08:32:00.000-07:00</published><updated>2009-04-30T11:46:41.578-07:00</updated><title type='text'>Enumerating reporting services metadata with C# and SQL Server 2005</title><content type='html'>&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;Who should read this article&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;Report writers, database developers, data modelers, anyone familiar with SQL Server 2005 &amp;amp; 2008 Reporting Services (familiarity with Report Models, Report Designer and Report Builder) and lastly with some knowledge of programming with C# and XML.&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;br /&gt;Introduction &lt;/span&gt;&lt;br /&gt;Why should report model metadata be stored (in a metadata repository)? This could be a question you are asking yourself or you already know the answer and are looking for additional silver bullets to help explain it to your manager or project sponsor.&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;One of the more compelling reasons for capturing metadata about entities and attributes (and to an extent – roles &amp;amp; relationships) in reporting services report models in any organization is ‘documentation’. May that be client documentation or in-house documentation to serve as a reference guide for business users, or as a technical reference for ETL developers, or for that new developer who just joined you organization and wanted to know the definition or description of a business term, or more importantly as a quick reference for report writers (who may not be familiar with the field names used in the report model). Whichever the use; the bottom line lies in the term ‘Metadata Management’ (not to be confused with Master Data Management – an entirely different topic).&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;The objective of this article is to extract from the smdl file using C#, meaningful and necessary metadata and store it in a SQL Server 2005 database.&lt;/span&gt;  &lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;&lt;br /&gt;&lt;br /&gt;Report Authors&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;I separated the report writers based on method of developing reports:&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;1. Using Report Designer (from Visual Studio or BIDS) for canned\ known reports - Technical Report writers&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;Technical Report writers are usually report developers who are familiar with the data model and may\may not know much about business processes.&lt;br /&gt;2. Using Report Builder (spawning from the browser) for ad-hoc reports - Ad-hoc report writers.&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;Ad-hoc report writers are usually business users (end users working on the application or management folks).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;This blog is more inclined towards the ad-hoc report writer community.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;If you are interested in knowing more about metadata and metadata driven architectures you will have to wait until my next article or just google ‘Metadata driven architecture’ and ‘Microsoft Project Real’. Microsoft’s Project Real has a good implementation of metadata (open source) for enumerating and storing metadata in the database for SSIS, SSAS and for database structures, but lacks a module for enumerating Reporting Services models.&lt;/span&gt;  &lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;&lt;br /&gt;&lt;br /&gt;Report Models&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;A Report model is a slice of information of the database structure (views and\or tables) that relates to a specific business scope. For example, in an automobile dealership data warehouse one of the report models would be a Sales model which links back to an inventory table and a date time dimension. Report models are created with a ‘data source view’ reference. Think of a ‘Data Source View’ as a visual representation of a database diagram with tables or views having keys and relationships. Report models are created with the end user perspective as they use report models as their source to build ad-hoc reports.&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;br /&gt;Note: Report models have a file extension of smdl. The content of these ‘smdl’ files is a set of XML nodes describing the model (They contain entities, attributes, rules, roles, relationships, etc).&lt;/span&gt;  &lt;span style=&quot;font-weight: bold;font-family:verdana;&quot; &gt;&lt;br /&gt;&lt;br /&gt;Creating the metadata repository for Report Models&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;The report model repository can be created as a separate schema with a set of tables or be a part of your own custom metadata solution; or feel free to use the scripts and schema I provide in this article.&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;Once your schema is created; two stored procedures need to be created for inserting into the Entity table and the Attribute table. You could create simple CRUD type procedures that do a one row insert at a time, but a more efficient solution would be to create OPENXML stored procedures to insert all the data in one call. In my example I used the latter. By using the OPENXML stored procedure that I reduced the number of database inserts calls from hundreds to one. I have provided the code for the OPENXML stored procedures at the end of the article.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_SkMr_IF6CwU5GPX78_4tNclrAXPc9pck3buwQuwj5bHx9zwxZ8d_21P_m8KdhbI03n1L3bcT64xQ4JQcQ4w4aG701fKgrJ4X-tdrziLDLYUxqO1AFkIW5iMJDtQZPrFBoVEx_jQugBY/s1600-h/MetadataStore.jpg&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 114px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_SkMr_IF6CwU5GPX78_4tNclrAXPc9pck3buwQuwj5bHx9zwxZ8d_21P_m8KdhbI03n1L3bcT64xQ4JQcQ4w4aG701fKgrJ4X-tdrziLDLYUxqO1AFkIW5iMJDtQZPrFBoVEx_jQugBY/s320/MetadataStore.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5327149745084107730&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Figure 1: Report Model schema.&lt;/span&gt;   &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;br /&gt;Now that your schema and stored procedures (“AddAttribute” and “AddEntity”) are created (and tested), you can begin with the application code.&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;At this point&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;- Make a copy of the Report Model file from which metadata needs to be extracted from.&lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;br /&gt;Extracting data from the Report Model&lt;/span&gt; (.smdl): There are various ways of retrieving this report model data from the smdl file; like using XSLT and XPATH in C# to get to the desired nodes; or store XML chunks of the model file as XML data type in SQL Server and retrieve it based on XQUERY. Any way can be adopted; i will demonstrate one &#39;simple&#39; way of doing it. You could apply a similar extraction and storage technique for report files (rdl files).&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;br /&gt;For my solution i used a C# windows application solution in Visual Studio. You could even create a console app instead of windows. I created a windows app so that i could have the feature of browsing for .smdl files without having to type it in.&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;Basically, the extract from smdl (XML) files was done by using XMLTextReader class provided in the System.XML namespace. I parsed the entire XML file for tags (XMLNodeType), in a specific format hierarchically based on the XML node structure (Entity --&gt; Attribute --&gt; Attribute Properties).&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;br /&gt;Each line in the XML supports these tags to identify the item associated with it. Once a type (XMLNodeType) name &quot;Attribute&quot; is found, i look for additional properties of the nodes with tags &quot;Name&quot;, &quot;DataType&quot;, &quot;Nullable&quot;, &quot;Format&quot;, &quot;SortDirection&quot;, &quot;ColumnName&quot;, &quot;Description&quot; etc. and start building my XML string structure.&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;A few functionalities provided by the XMLNodeType (and how they were used):&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;1. XmlNodeType.Element: Used for element level parsing.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;2. XmlNodeType.Text: Text content of a node to retrieve description of a column, etc.&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;3. XmlNodeType.EndElement: To find the exit point of an element (entity, attribute, or anything else)&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;br /&gt;An important thing to note here is that i am NOT retrieving values based on keys and inserting to the metadata store. I am actually building a well formatted valid XML string that will contain the key-value mapping structure so that it can be passed to the SaveAttribute and SaveEntity methods (OPENXML stored procedures).&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;Once this XML string is created it is passed to the methods SaveAttribute (executes stored proc AddAttribute) and SaveEntity (executes stored proc AddEntity). Both these methods execute with one call each to the database.&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;The relationship between an attribute and its parent entity is also saved to the database table based on GUIDs.&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;Following is a sample of the data from the metadata repository.&lt;/span&gt;  &lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBdgFLa75OPReJOsRCy5dYWX2WUaSOC9HCinTW0Lvg_OPvFVbAFKxp94JwmpEtZf0sFHLJFuQ2O9pTk-WtuYWGMM3N37wFtJlIwG4iCqDXgU9LIWDDX4VeIKfhzpVmu_CkcNZYuBHB7YQ/s1600-h/SampleMetadata.JPG&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 78px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBdgFLa75OPReJOsRCy5dYWX2WUaSOC9HCinTW0Lvg_OPvFVbAFKxp94JwmpEtZf0sFHLJFuQ2O9pTk-WtuYWGMM3N37wFtJlIwG4iCqDXgU9LIWDDX4VeIKfhzpVmu_CkcNZYuBHB7YQ/s320/SampleMetadata.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5327150393903611106&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Figure 2: Sample data view.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Figure 3: Sample OPENXML stored procedure content (where @AttributeXML is the XML string created by the C# code):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRCdDKrcr94gunzcS8QFnmeKMrLGdJ6cx2-5_ARrsauB0FXkyya92Yfeet_e5-IcJ8ux2y8p6GxOkQDzk6nFolvKz7Hinw3ydMb1IqrFT-2QZI8RpYIFEpY2buMvTzP-SKZjyC2JjNSBo/s1600-h/OPENXMLStoredProc.JPG&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 318px; height: 320px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRCdDKrcr94gunzcS8QFnmeKMrLGdJ6cx2-5_ARrsauB0FXkyya92Yfeet_e5-IcJ8ux2y8p6GxOkQDzk6nFolvKz7Hinw3ydMb1IqrFT-2QZI8RpYIFEpY2buMvTzP-SKZjyC2JjNSBo/s320/OPENXMLStoredProc.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5327217888500899298&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Summary &lt;/span&gt;&lt;br /&gt;The idea behind this article is to give the community another way of retrieving metadata from report models. This would be a good addition to the existing BI metadata repositories that companies currently support. One really has to understand and harness the power of metadata. There are people who do not support the idea behind metadata and its use. Think of a simple scenario (a real world project) of metadata use - A project for migrating around 1000 tables with millions of rows transactional data from AS400 i-series to SQL Server 2008 using SSIS, so, were you going to create source, staging and warehouse structures manually? I don&#39;t think so, Ideally you would retrieve all the metadata from the system catalog of AS400 and write dynamic SQL scripts to create all the structures.&lt;/span&gt; &lt;span style=&quot;font-family:verdana;&quot;&gt;Long story short - utilize metadata to the fullest extent, maintain a store of the metadata for business, technical and ETL process meta data and incorporate it during the earlier phases of your BI projects. Hope this was helpful. Do leave feedback. &lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;br /&gt;Download code: &lt;a href=&quot;http://www.mediafire.com/?5kznjoxik1j&quot;&gt;Download Code here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.blogger.com/%27http://www.mediafire.com/?gtw4jmlmzer%27&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Thanks,&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Vishal Gamji &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;i style=&quot;&quot;&gt;MCITP - Database  Developer&lt;/i&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;a href=&quot;mailto:admin@expertsqltraining.com&quot;&gt;admin@expertsqltraining.com&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlscape.blogspot.com/feeds/774889483522449666/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlscape.blogspot.com/2009/04/enumerating-reporting-services-metadata.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/774889483522449666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/774889483522449666'/><link rel='alternate' type='text/html' href='http://sqlscape.blogspot.com/2009/04/enumerating-reporting-services-metadata.html' title='Enumerating reporting services metadata with C# and SQL Server 2005'/><author><name>Vishal Gamji</name><uri>http://www.blogger.com/profile/17339519129020034877</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_SkMr_IF6CwU5GPX78_4tNclrAXPc9pck3buwQuwj5bHx9zwxZ8d_21P_m8KdhbI03n1L3bcT64xQ4JQcQ4w4aG701fKgrJ4X-tdrziLDLYUxqO1AFkIW5iMJDtQZPrFBoVEx_jQugBY/s72-c/MetadataStore.jpg" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1061402500983800988.post-6138542309483731615</id><published>2009-03-14T06:31:00.000-07:00</published><updated>2009-04-21T08:49:19.775-07:00</updated><title type='text'>SSIS Execute SQL Task failure</title><content type='html'>&lt;i style=&quot;&quot;&gt;&lt;span style=&quot;;font-family:&#39;Arial&#39;,&#39;sans-serif&#39;;color:red;&quot;  &gt;&lt;/span&gt;&lt;/i&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;i style=&quot;&quot;&gt;&lt;span style=&quot;color:red;&quot;&gt;Possible failure reasons: Problems with the  query, &quot;ResultSet&quot; property not set correctly, parameters not set correctly, or  connection not established correctly.&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;i style=&quot;&quot;&gt;&lt;span style=&quot;color:red;&quot;&gt;&lt;br /&gt;               &lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;                                                                                                                                          &lt;/span&gt; &lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;      Every so often ETL developers working with the Execute SQL Task in SSIS  encounter the error above. I have seen a few developers who try to &#39;quick-fix&#39;  this by changing type mappings without exactly knowing the differences between  them and re-running the ETL task only to get to the next red light. The best  example of this would be the type mismatch of Long and Numeric types  when using the native OLEDB provider. I wouldn&#39;t be surprised if there are  developers out there looking up the precision error on the types. I will not  delve too deep into all the providers, but will provide a reference to a very  good resource that Microsoft has provided, and which I think should be on every  ETL developer&#39;s desk.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;                                       &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;In this (first) blog I will point out the most common places in the  Execute SQL Task where you should troubleshoot the error (above). Will also go  over some SQL provider mumbo jumbo at a high level. &lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Troubleshooting steps (order need not be  followed):&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt; &lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;1.  &lt;b style=&quot;&quot;&gt;Verify that for the stored procedure\SQL  statement used, the parameter counts and direction (input, output or return  value) is set appropriately&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt; text-indent: 0.5in;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;                                                                                       &lt;/span&gt; &lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt; text-indent: 0.5in;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;If using a OLEDB or ODBC provider check if your number of &quot;?&quot;  (parameters), and if using ADO or ADO.NET provider, check the number of  @&lt;paramname&gt; are equal to the number of parameters being mapped to on the  parameter mapping screen.&lt;/paramname&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt; text-indent: 0.5in;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;paramname&gt;&lt;br /&gt;&lt;/paramname&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt; &lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;2.  &lt;b style=&quot;&quot;&gt;Verify your data  types&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;                                                                                      &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Verify that the data types that exist\declared in the stored procedure or  SQL are mapped to a compatible data type in the parameter mapping. For example:  when using the OLEDB provider, map the integer (int) parameters to Long data  type.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Providers&lt;/span&gt;:  Which data provider should be used when choosing between (Managed) ADO.NET or  (Native) OLEDB?&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;- There are &lt;i style=&quot;&quot;&gt;n&lt;/i&gt; number of websites and blogs (yes,  this is also another one of them) which will tell you why you should prefer the  use of OLEDB provider over ADO.NET, as ADO.NET&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;is a managed  provider which adds another layer code to connect to the data source, thus  making ADO.NET slower than OLEDB. If you really want to find the exact runtime  exection difference I would suggest running profiler with the two connection  managers and then comparing them.&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;                                            &lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;         &lt;/span&gt; &lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Helpful links for data type mapping and provider info:&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;-   &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa198346%28SQL.80%29.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/aa198346(SQL.80).aspx&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;-   &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa263420.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/aa263420.aspx&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;-   &lt;a href=&quot;http://www.carlprothman.net/Default.aspx?tabid=97#10&quot;&gt;http://www.carlprothman.net/Default.aspx?tabid=97#10&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;a href=&quot;http://www.carlprothman.net/Default.aspx?tabid=97#10&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt; &lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;3.  &lt;b style=&quot;&quot;&gt;Verify the ResultSet  property&lt;/b&gt;:&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;&lt;/span&gt;Verify that the &lt;i style=&quot;&quot;&gt;ResultSet&lt;/i&gt; property  is set appropriately for the SQL command being executed. For example: if the SQL  command\stored procedure returns a full result set, set it to the &#39;Object&#39; data  type, so that you can retrieve from the object based on the index position of  the result (0 = first column, 1 = second column and so on) as members of the  &#39;Object&#39; type are ordinal. Also make sure that all columns in the sql result set  have column names.&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;4.  &lt;b style=&quot;&quot;&gt;Do you trust your SQL Command\Stored  procedure, there is a very good possibilty if it being incorrect&lt;/b&gt;:   &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;                                                                                                      &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;&lt;/span&gt;The execute SQL task can do nothing about  bad\erroneous SQL code given to it for execution but fail it. As a routine, test  the SQL for all possible exceptions, giving more importance to situations where  a value or a list of values is expected and nothing is returned.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;For  example: the sub query inside the stored procedure may be returning multiple  values, NULL\invalid or no values at all. Watch out for the tricky no value  situation.                             &lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Example: In this example, our  objective is to retrieve &lt;i style=&quot;&quot;&gt;object_id&lt;/i&gt;  from &lt;i style=&quot;&quot;&gt;sys.objects&lt;/i&gt; where the &lt;i style=&quot;&quot;&gt;name&lt;/i&gt; meets a  certain condition. The &#39;ResultSet&#39; property of the execute sql task is being set  to &quot;Single Row&quot; (as our objective is to retrieve a scalar  value).&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;[Note: Each Case builds  on the previous cases.]&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;         &lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Case 1&lt;/span&gt;: Simple Select to  assign to a variable&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;span style=&quot;color:fuchsia;&quot;&gt;object_id&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;FROM&lt;/span&gt;  &lt;span style=&quot;color:green;&quot;&gt;sys.objects&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;WHERE&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color:gray;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color:red;&quot;&gt;&#39;sysrowsets&#39;;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;                                                   &lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;If the result set of the execute sql  task is set to &quot;Single Row&quot;, it will work only when the WHERE condition is  satisfied. If it is not satisfied, it does not return NULL, instead returns  nothing, i.e. an empty result set (see screenshot below) - which will cause the  task to fail giving us the same error &quot;&lt;i style=&quot;&quot;&gt;ResultSet property not set correctly&lt;/i&gt;&quot;. [A developer must keep this exception in mind when testing  the execute sql task]. This query will also raise an exception when multiple  values are returned by the query and our task is to assign a single value to a  variable from the output of our query.&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Case  2&lt;/span&gt;: Handle multiple values.     &lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;  @Object_ID &lt;span style=&quot;color:blue;&quot;&gt;int;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;SET&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;  @Object_ID &lt;span style=&quot;color:gray;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color:gray;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;TOP&lt;/span&gt; 1 &lt;span style=&quot;color:fuchsia;&quot;&gt;object_id&lt;/span&gt;  &lt;span style=&quot;color:blue;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color:green;&quot;&gt;sys.objects&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;WHERE&lt;/span&gt;  &lt;span style=&quot;color:blue;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color:gray;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color:red;&quot;&gt;&#39;sysrowsets&#39;&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;                               &lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;In this case, we handled the  multiple values problem from Case1. Now, if the result set returns anything  other than a NULL value or a Non-Empty value, we are close to living in a  perfect world, but, as it turns out (someone told me) that we don&#39;t.&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;If\When a NULL or  an empty result is returned by the above query an exception will be thrown. Yes;  it is the same exception we are discussing in this article.&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt; text-indent: 0.5in;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt; text-indent: 0.5in;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;I am  more inclined on the &#39;When&#39; it will happen than the &#39;if&#39; possibility because  at-least in the scenarios I have worked with, it was bound to happen, then  again, your case may be different.                                     &lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;         &lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Case 3&lt;/span&gt;: Split the simple  select into &#39;simpler&#39; select.&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;  @Object_ID &lt;span style=&quot;color:blue;&quot;&gt;int;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;SET&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;  @Object_ID &lt;span style=&quot;color:gray;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color:gray;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;TOP&lt;/span&gt; 1 &lt;span style=&quot;color:fuchsia;&quot;&gt;object_id&lt;/span&gt;  &lt;span style=&quot;color:blue;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color:green;&quot;&gt;sys.objects&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;WHERE&lt;/span&gt;  &lt;span style=&quot;color:blue;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color:gray;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color:red;&quot;&gt;&#39;sysrowsets_&lt;b style=&quot;&quot;&gt;Bogus&lt;/b&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;color:gray;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//Comments-The  &lt;/span&gt;&lt;b style=&quot;&quot;&gt;&lt;span style=&quot;color:red;&quot;&gt;_Bogus&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color:green;&quot;&gt; makes the query to  return an empty result set.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;;font-size:100%;color:blue;&quot;  &gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;span style=&quot;color:fuchsia;&quot;&gt;ISNULL&lt;/span&gt;&lt;span style=&quot;color:gray;&quot;&gt;(&lt;/span&gt;@Object_ID&lt;span style=&quot;color:gray;&quot;&gt;,&lt;/span&gt; 0&lt;span style=&quot;color:gray;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color:red;&quot;&gt;&#39;Object_ID&#39;;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;color:red;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;                                    &lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;The first Select statement here takes  care of multiple values; the second Select statement handles any NULL values and  sets it to 0 and also solves the &#39;empty&#39; result set problem when the &lt;i style=&quot;&quot;&gt;&lt;span style=&quot;&quot;&gt;@Object_ID&lt;/span&gt;&lt;/i&gt; is selected separately in a  different query (as the 2&lt;sup&gt;nd&lt;/sup&gt; query).&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;b style=&quot;&quot;&gt;Summary&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;                           &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;&quot;&gt;             &lt;/span&gt;&lt;/span&gt;To summarize, double check your SQL queries\Stored procedures before you  execute them in the &lt;i style=&quot;&quot;&gt;ExecuteSQLTask&lt;/i&gt;. Don&#39;t jump to hasty conclusions about  the error message description Integration Services provides you. For instance if  you get any &#39;Arithabort error&#39; [Ex: &lt;span style=&quot;color:red;&quot;&gt;Update  failed because the following SET options have incorrect settings:  &#39;ARITHABORT&#39;&lt;/span&gt;] on a  stored procedure that performs an insert\update\delete - check the database  compatibility level (sp_dbcmptlevel) which maybe a SQL Server 2000 database with  setting 80 and needs to be upgraded to compatibility level 90 of SQL Server  2005, or verify if any columns are computed columns performing calculations  which may be throwing arithabort errors. Check for any external factors that are  affecting your ExecuteSQLTask variables, for instance package configurations or  dynamic expressions. Performing these checks will surely save you some time in  the long run and also make your packages robust.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;                                      &lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style=&quot;margin: 0in 0in 0pt;font-family:verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Hope this article\blog  was helpful. Do leave a feedback (as this is my first blog). My next blog is  about enumerating Reporting Services metadata from models into a database  repository. Hope to get it out soon.&lt;/span&gt;&lt;/p&gt;&lt;p face=&quot;verdana&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p face=&quot;verdana&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p face=&quot;verdana&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Thanks,&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot;margin: 0in 0in 0pt; font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;Vishal Gamji &lt;/span&gt;&lt;/p&gt; &lt;p style=&quot;margin: 0in 0in 0pt; font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;i style=&quot;&quot;&gt;MCITP - Database  Developer&lt;/i&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p style=&quot;margin: 0in 0in 0pt; font-family: verdana;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;a href=&quot;mailto:admin@expertsqltraining.com&quot;&gt;admin@expertsqltraining.com&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;  &lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlscape.blogspot.com/feeds/6138542309483731615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlscape.blogspot.com/2009/04/execute-sql-task-failure-possible.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/6138542309483731615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1061402500983800988/posts/default/6138542309483731615'/><link rel='alternate' type='text/html' href='http://sqlscape.blogspot.com/2009/04/execute-sql-task-failure-possible.html' title='SSIS Execute SQL Task failure'/><author><name>Vishal Gamji</name><uri>http://www.blogger.com/profile/17339519129020034877</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>