<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" 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" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-4845744956082769684</atom:id><lastBuildDate>Wed, 15 May 2013 13:33:48 +0000</lastBuildDate><category>Virtual Machine</category><category>Scripting</category><category>Book Review</category><category>VM</category><category>PowerShell</category><category>Performance</category><category>MySQL</category><category>SQL</category><category>Cooking</category><category>Version Control</category><category>Sharepoint</category><category>SQL Server</category><category>VSTS DB Pro</category><category>XML</category><category>Powerpivot</category><category>SQL Project</category><category>SSIS</category><category>Service Broker</category><category>SSDT</category><title>Schott SQL</title><description /><link>http://schottsql.blogspot.com/</link><managingEditor>noreply@blogger.com (Peter Schott)</managingEditor><generator>Blogger</generator><openSearch:totalResults>43</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SchottSql" /><feedburner:info uri="schottsql" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-281584111433183823</guid><pubDate>Tue, 14 May 2013 20:16:00 +0000</pubDate><atom:updated>2013-05-15T08:33:48.544-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">VSTS DB Pro</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Setting Different Permissions per Environment</title><description>&lt;p&gt;One of the areas that SSDT doesn't address adequately is permissions. Many users have different users, logins, and permissions set up across their environments, but SSDT takes a "one size fits all" approach and assumes that you will have the exact same configuration in each environment. While that should be the case for your schema, this area requires some interesting and somewhat involved techniques to handle well in SSDT.  &lt;p&gt;Attribution - I'm borrowing heavily from Jamie Thomson's ( &lt;a href="http://sqlblog.com/blogs/jamie_thomson/default.aspx" target="_blank"&gt;blog&lt;/a&gt; | &lt;a href="https://twitter.com/jamiet" target="_blank"&gt;twitter&lt;/a&gt; ) post  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/07/21/a-strategy-for-managing-security-for-different-environments-using-the-database-development-tools-in-visual-studio-2010.aspx" target="_blank"&gt;A strategy for managing security for different environments using the Database Development Tools in Visual Studio 2010&lt;/a&gt;  &lt;p&gt;Jamie addressed this problem for the older DB Projects (Datadude, VSTSDB, DBPro, etc.). He came up with an excellent, if somewhat complex, solution to effectively handle pushing different permissions to different environments. This is my attempt to update this and distill it into a "how to" for SSDT and SQL Projects, but I freely admit that this is based on Jamie's excellent work.  &lt;p&gt;In general, the steps we'll want to take are:  &lt;ol&gt; &lt;li&gt;Generate a set of SQL Logins that will be used on the server.  &lt;ol&gt; &lt;li&gt;These should be run on the servers or local box already - we will not use these within the SQL Project itself though you can if you wish.&lt;/li&gt;&lt;/ol&gt; &lt;li&gt;Generate the files for users/roles/permissions for each database project and environment.  &lt;li&gt;Add the files to your SSDT SQL Project  &lt;li&gt;Create and set a variable for your environments in your SSDT SQL Project.  &lt;li&gt;Adjust your Security Wrapper file to handle your environments.  &lt;li&gt;Adjust your post-deploy script to call the Security Wrapper.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;First, let's look at what happens when you import Permissions by default into an SSDT SQL Project.  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-zOICJmsSn0c/UZKbb4QgGEI/AAAAAAAAHU0/4MMOy_ReFDY/s1600-h/clip_image001%25255B3%25255D.png"&gt;&lt;img title="clip_image001" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image001" src="http://lh6.ggpht.com/-12u45mChKxg/UZKbcaNmC2I/AAAAAAAAHU8/Qn5mr70Grhk/clip_image001_thumb.png?imgmax=800" width="182" height="184"&gt;&lt;/a&gt;  &lt;p&gt;As you can see from the screenshot, we have a "Permissions" file containing granted permissions, a "RoleMemberships" file that adds users to various roles, a "Sales" file for the Sales schema, and 3 files each for the users - one for its schema, one for its login, and another for its user. Confusing, but not necessarily a problem until you need a release where User1 does not and will not exist on the server or where User2 belongs to a different domain than your production servers and can't and should not be created there because there's no trust relationship.  &lt;p&gt;Let’s remove all of those files for objects other than Schemas from the project before we start. You’ll probably have to look at each file to verify before removing it from the project if you’re not sure which file is which. If you accidentally remove the files for the schemas, you’ll get errors and need to re-add a “Schema” to this security folder for each schema that is used.  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Generate SQL Logins&lt;/strong&gt;  &lt;p&gt;&lt;a href="http://support.microsoft.com/kb/246133" target="_blank"&gt;This Microsoft KB article&lt;/a&gt; details the sp_help_revlogin stored procedure. Create this on your source database, run it, and use the output to re-create those logins elsewhere. This will copy all logins and users, but no permissions or database users.  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Generate the Security Files through PowerShell&lt;/strong&gt;  &lt;p&gt;First, download the &lt;a href="http://sdrv.ms/13kJRHo" target="_blank"&gt;Powershell_GeneratePermissions.zip&lt;/a&gt; file. Extract that to a folder on your hard drive.  &lt;p&gt;Note - the script assumes that you will use Windows authentication to connect to your SQL Server. The script will need to be adjusted if you need to use SQL Authentication.  &lt;p&gt;Edit the "GeneratePermissions.ps1" file. Replace the "DB1", "DB2", etc with whatever database names you'll be using. Also uncomment any of the extra lines that you'll need in the file. (There is likely a better way to do this in Powershell and I'm more than open to some suggestions on how to build up this array in a more concise manner.)  &lt;p&gt;The assumption is made that the databasename == the projectname. If that's not the case, adjust your DB/Project names accordingly.  &lt;p&gt;Open a PowerShell prompt in that folder after editing/saving the file.  &lt;p&gt;Run the file using something like this commandline:  &lt;p&gt;.\GeneratePermissions.ps1 -SQLInstance "localhost" -Environment DEV  &lt;p&gt;"localhost" should be replaced with your servername  &lt;p&gt;DEV in this case indicates that this will be tied to a variable value of "DEV" when the project is published.  &lt;p&gt;I'd recommend running this for every environment at one time if you can. It will make adding the files to the project much easier.  &lt;p&gt;If you run for several environments, you'll see a folder structure something like the following for each project (in this case for Adventureworks2012):  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-pbkwK6KsNrU/UZKbc-N4JdI/AAAAAAAAHVE/8WF0d-D7WvM/s1600-h/clip_image002%25255B3%25255D.png"&gt;&lt;img title="clip_image002" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image002" src="http://lh5.ggpht.com/-3JScHSXYMo8/UZKbdesVopI/AAAAAAAAHVM/fRD4VA0Vz8U/clip_image002_thumb.png?imgmax=800" width="174" height="155"&gt;&lt;/a&gt;  &lt;p&gt;Inside your "SecurityAdditions" folder, you'll see the following files and folders:  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-8uIjbyNCJys/UZKbeN0WEuI/AAAAAAAAHVU/yFda0DAdXR0/s1600-h/clip_image003%25255B3%25255D.png"&gt;&lt;img title="clip_image003" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image003" src="http://lh3.ggpht.com/-3IuRf5e7178/UZKbenYeEyI/AAAAAAAAHVc/fOl8TaWREuY/clip_image003_thumb.png?imgmax=800" width="244" height="166"&gt;&lt;/a&gt;  &lt;p&gt;Each of these files will be used to add permissions for each environment. In this case, we have permissions set for our Development, QA, Local, Production, and Staging environments.  &lt;p&gt;Now, let's add the "SecurityAdditionsWrapper.sql" file from the files we extracted earlier into your "SecurityAdditions" folder. Feel free to edit it as needed to match the environment(s) you want to use for your database project. By default, it's set to look for the above files plus a "Default" file to be a catch-all. Adjust that so all files/environments match the files you created and save it.  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Add the files to your SSDT SQL Project&lt;/strong&gt;  &lt;p&gt;Copy your newly created folder(s) to the appropriate project. Open each project, and you will notice that the files still don't show up. Click the project file. You should see a menu item that's now enabled to "show all files".  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-tgKMyJo4mEk/UZKbfYrkjMI/AAAAAAAAHVk/3BuEy8EXNyw/s1600-h/clip_image004%25255B3%25255D.png"&gt;&lt;img title="clip_image004" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image004" src="http://lh4.ggpht.com/-WNHQN0Az_VA/UZKbgcFMfvI/AAAAAAAAHVs/lHnb4fUhaBc/clip_image004_thumb.png?imgmax=800" width="244" height="85"&gt;&lt;/a&gt;  &lt;p&gt;You'll see a bunch of files that aren't part of the project under a "Scripts" folder:  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-53qriVEEndU/UZKbhDgidLI/AAAAAAAAHV0/OaR3NZ6JZW0/s1600-h/clip_image005%25255B3%25255D.png"&gt;&lt;img title="clip_image005" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image005" src="http://lh5.ggpht.com/-QiIMWEPXxyY/UZKbhooshwI/AAAAAAAAHV8/mJFknV0ZJ8I/clip_image005_thumb.png?imgmax=800" width="244" height="82"&gt;&lt;/a&gt;  &lt;p&gt;We want to add them to the project. Right-click the "Scripts" folder and select the option to "Include in Project". Click the Project file again and turn off the option to show all files.  &lt;ul&gt; &lt;li&gt;We need to set all file properties to "Not in Build" or there will be errors when trying to build the project.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Unfortunately, we can't select just the folder to exclude from the build. We need to select the files. You can ctrl+click to select multiple files. Select all of the files, open the Properties tab, and change the option from "Build" to "None"  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-0Zm0pQMofjo/UZKbiNIcBvI/AAAAAAAAHWE/-BdFpZSk46M/s1600-h/clip_image006%25255B3%25255D.png"&gt;&lt;img title="clip_image006" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image006" src="http://lh3.ggpht.com/-Fkfyxy2hcAg/UZKbiuXan-I/AAAAAAAAHWM/2Jq1qkGSuA4/clip_image006_thumb.png?imgmax=800" width="244" height="94"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Create and set your Variable to change environments&lt;/strong&gt;  &lt;p&gt;Open the Project Properties window  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-Dc36OfWrm9Y/UZKbi4zO_XI/AAAAAAAAHWU/3fYUrK0lNUk/s1600-h/clip_image007%25255B3%25255D.png"&gt;&lt;img title="clip_image007" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image007" src="http://lh3.ggpht.com/-d_49IO669b0/UZKbjcirmII/AAAAAAAAHWc/3RVe8xjejVE/clip_image007_thumb.png?imgmax=800" width="244" height="57"&gt;&lt;/a&gt;  &lt;p&gt;We want to change the SQLCMD variable to add a new variable called "DeployType". Set it's default value to "Local" for now, or whatever environment for which you have a set of security scripts.  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-rHVNQDWjjvY/UZKbj7kigOI/AAAAAAAAHW8/LHNhZnM2iAQ/s1600-h/clip_image008%25255B4%25255D.png"&gt;&lt;img title="clip_image008" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image008" src="http://lh4.ggpht.com/-7-OOoBHvRkk/UZKbkdokxqI/AAAAAAAAHXA/vT3j_VoaaSA/clip_image008_thumb%25255B1%25255D.png?imgmax=800" width="518" height="207"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Adjust your Security Wrapper files&lt;/strong&gt;  &lt;p&gt;The SecurityAdditionsWrapper.sql file in the code set I've created comes with settings for "Dev", "QA", "Staging", "Production", "Local", and "Default". It's likely that you will not use all of these in your setting. One drawback to using SQLCMD to wrap all these files together is that if you don't have a file or set of files, the script will start throwing errors because an expected file doesn't exist. Edit the SecurityAdditionsWrapper.sql file to remove any of the configurations you will not use or change the names to match the environment values you used earlier.  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Adjust your Post-Deploy script&lt;/strong&gt;  &lt;p&gt;Finally, we need to open your Post-Deploy script.  &lt;p&gt;Add the following to your script:  &lt;p&gt;:r .\SecurityAdditions\SecurityAdditionsWrapper.SQL  &lt;p&gt;This will include your SecurityAdditionsWrapper file as part of your post-deploy process. See my earlier post on &lt;a href="http://schottsql.blogspot.com/2013/05/trick-to-not-run-prepost-sql-on-publish.html"&gt;selectively running pre/post deploy scripts&lt;/a&gt; if you want finer control.&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/2iFDYKoJWrk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/2iFDYKoJWrk/ssdt-setting-different-permissions-per.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-12u45mChKxg/UZKbcaNmC2I/AAAAAAAAHU8/Qn5mr70Grhk/s72-c/clip_image001_thumb.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2013/05/ssdt-setting-different-permissions-per.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-5492574337449992749</guid><pubDate>Tue, 14 May 2013 20:06:00 +0000</pubDate><atom:updated>2013-05-14T15:06:13.469-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">VSTS DB Pro</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>Trick to Not Run Pre/Post SQL on Publish</title><description>&lt;p&gt;We’ve run across the need to avoid running certain scripts when publishing a brand new copy of a database from a SQL or DB Project from time to time. Often, those pre/post deploy scripts are designed to be run only against an existing system and don’t make sense for a brand-new, empty database.&lt;br&gt;&lt;/p&gt; &lt;p&gt;We’ve worked around this by using a SQLCMD variable called &lt;em&gt;DeployType&lt;/em&gt; and setting that variable to “New” for any build operation that will be used only to create the initial database. The code snippet for our Post-Deploy script looks something like the following:&lt;/p&gt; &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&lt;font color="green"&gt;&lt;i&gt;-- Place scripts here if they should only run for existing/working DB&lt;/i&gt;&lt;/font&gt;&lt;br&gt;&lt;font color="blue"&gt;IF&lt;/font&gt;&amp;nbsp;&lt;font color="maroon"&gt;(&lt;/font&gt;&amp;nbsp;&lt;font color="red"&gt;'$(DeployType)'&lt;/font&gt;&amp;nbsp;&lt;font color="silver"&gt;&amp;lt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="red"&gt;'New'&lt;/font&gt;&amp;nbsp;&lt;font color="maroon"&gt;)&lt;/font&gt; &lt;br&gt;&amp;nbsp; &lt;font color="blue"&gt;BEGIN&lt;/font&gt;&amp;nbsp;&lt;font color="green"&gt;&lt;i&gt;--Run scripts&lt;/i&gt;&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="blue"&gt;PRINT&lt;/font&gt;&amp;nbsp;&lt;font color="red"&gt;'Deploying scripts.'&lt;/font&gt; &lt;br&gt;&amp;nbsp; &lt;font color="blue"&gt;END&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&lt;font color="green"&gt;&lt;i&gt;--Security - runs last&lt;/i&gt;&lt;/font&gt; &lt;br&gt;&lt;font color="gray"&gt;:r .\SecurityAdditions\SecurityAdditionsWrapper.sql&lt;/font&gt; &lt;br&gt;&lt;/p&gt;&lt;/font&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The above script will look at the DeployType variable. If it’s set to “New”, it will ignore all of your deploy scripts in that block. If it’s set to any other environment, it will run the appropriate scripts if any exist. You can use this to control which environments will use certain scripts as well.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/m0cl6JfLcuc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/m0cl6JfLcuc/trick-to-not-run-prepost-sql-on-publish.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2013/05/trick-to-not-run-prepost-sql-on-publish.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-3194274560254786360</guid><pubDate>Thu, 24 Jan 2013 00:06:00 +0000</pubDate><atom:updated>2013-01-23T18:06:34.369-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT, Publishing, and Referenced Databases</title><description>Had this catch me today in a series of databases that all work together. In order to resolve all of the cross-database dependencies, I've added database references to the project. That takes care of all of the "Database.dbo.Object" references outside of the database. The problem is that &lt;i&gt;within&lt;/i&gt; the current database, you will get errors without that reference defined.&lt;br /&gt;
&lt;br /&gt;
In my haste to get the projects working, I added a database reference to the current project. I would build my project and reference the generated *.dacpac files when publishing. The problem is that every time I built my project, the &lt;i&gt;referenced&lt;/i&gt; dacpac file would overwrite the &lt;i&gt;generated&lt;/i&gt; dacpac file.&lt;br /&gt;
&lt;br /&gt;
Results from this problem - I noticed that my "DeployType" variable wasn't referenced anywhere, which struck me as odd because I use it in my Pre and Post Deploy scripts. I also started noticing that my dacpac file in my build folder was out of date, even after a successful build.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Workaround - do what I have done otherwise - replace all instances of &lt;i&gt;CurrentDatabaseName.dbo.&lt;/i&gt; with just &lt;i&gt;dbo.&lt;/i&gt; in all SQL files in the project.&amp;nbsp; This also includes the various forms that this can take:&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
&lt;i&gt;Databasename.dbo.&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Databasename..&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;[Databasename].[dbo].&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;etc&lt;/i&gt;&lt;/blockquote&gt;
&lt;br /&gt;
Once I replaced all of those references and rebuilt the project successfully, my publish actions started working again. My Deploy scripts were included. I didn't get mysterious warnings about my variables not existing.&lt;br /&gt;
&lt;br /&gt;
There may be a different way to work around self-referenced database objects within SSDT, but until I come across that, the workaround is to remove them from the code and &lt;i&gt;not&lt;/i&gt; to just add a reference to the current database through a dacpac file.&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/vO7lqlI9I2Q" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/vO7lqlI9I2Q/ssdt-publishing-and-referenced-databases.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2013/01/ssdt-publishing-and-referenced-databases.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-4265755853302731925</guid><pubDate>Wed, 14 Nov 2012 17:53:00 +0000</pubDate><atom:updated>2012-11-14T11:53:36.243-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SQL Server: Problems with corrupt files or assemblies</title><description>&lt;p&gt;Yesterday I found and fixed a bunch of hard drive issues. One of those issues resulted in my “Microsoft.AnalysisServices” assembly for SQL Server 2012 becoming corrupt. That in turn resulted in VS2010 throwing errors when I tried to use SSDT or do just about anything else. My exact error message was:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;Could not load file or assembly 'Microsoft.AnalysisServices, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The module was expected to contain an assembly manifest.&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;There was an MS help link as well, but it basically took me to a page that thanked me for letting them know they needed to work on their documentation. It was a little less than helpful.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I tried several things to fix the problem.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Re-apply SP1.&lt;/li&gt; &lt;li&gt;Uninstall just Analysis Services.&lt;/li&gt; &lt;li&gt;Repair SQL 2012&lt;/li&gt; &lt;li&gt;Uninstall SQL 2012&amp;nbsp; (This mostly worked except I still had issues with SSAS)&lt;/li&gt; &lt;li&gt;Reinstall SQL 2012&amp;nbsp; (This worked, but still had issues with Analysis Services)&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;All of the above resulted in the same error message at some point and a non-working install of SSAS 2012.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I finally came across an &lt;a href="http://forums.asp.net/t/1743386.aspx/1" target="_blank"&gt;article that talked about fixing the Global Assembly Cache&lt;/a&gt;. While not everything applied directly, it did get me started.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;I tried copying the &lt;em&gt;gacutil&lt;/em&gt; files as mentioned in the article. This didn’t work. The program ran, but didn’t do anything. I had to use the actual location for&amp;nbsp; &lt;em&gt;gacutil.exe&lt;/em&gt; in order to do anything. This can be found in “c:\Program Files (x86)\Microsoft SDKs\Windows\” You’ll need to choose the appropriate version for your OS as well as the appropriate choice for x32 or x64. In my case, it was Windows 8. My full path to &lt;em&gt;gacutil.exe&lt;/em&gt; was “C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64”&lt;/li&gt; &lt;li&gt;I had to find my physical Microsoft.AnalysisServices.dll file, found under “C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\SQLServer2012\x64”&lt;/li&gt; &lt;li&gt;After that, I was able to run &lt;strong&gt;gacutil -if “C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\SQLServer2012\x64\Microsoft.AnalysisServices.dll”&lt;/strong&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;After running that command, I uninstalled and re-installed SSAS under SQL 2012 using the standard add/remove features and everything is now working. I don’t know if anyone will encounter a similar problem with a bad assembly or assembly manifest, but hopefully this will help someone.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/tLs1kZWdOq4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/tLs1kZWdOq4/sql-server-problems-with-corrupt-files.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/11/sql-server-problems-with-corrupt-files.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-1391427315508196435</guid><pubDate>Mon, 12 Nov 2012 13:00:00 +0000</pubDate><atom:updated>2012-11-12T07:00:17.881-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Tips, Tricks, and Gotchas</title><description>&lt;p&gt;I wanted to add a short post to make sure I highlight some things that will trip people up or otherwise cause issues. &lt;p&gt;&amp;nbsp; &lt;ul&gt; &lt;li&gt;When setting trigger order for triggers on a table, you could run into an issue with Publishing your database. The project will build successfully, but throw a "Parameter cannot be null" error for parameter "Key". This is an internal bug with the product as of at least SQL 2012 CU2. It's been entered as an internal bug within MS with a workaround. To workaround the issue, do not try to set the trigger order in the table definition, but rather put this code in a post-deploy script.&lt;/li&gt; &lt;ul&gt; &lt;li&gt;This is supposed to be fixed in a future release of SSDT so your experience may vary.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;Importing encrypted objects may fail. If you want to store encrypted objects in your project, you'll likely need the code in order to create them in the project.&lt;/li&gt; &lt;li&gt;Unlike the Schema Compare option in VS 2010, there is no way to set the default Schema Compare options nor a way to filter out "skipped" objects in the schema compare.&lt;/li&gt; &lt;ul&gt; &lt;li&gt;I’d love some ideas on how better to handle this. You may be able to save the compare within the project for future re-use, but I had little success with this in VS 2010 Projects so have been reluctant to try that route again.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;If your database uses FILESTREAM, you will not be able to debug using the default user instance that SSDT provides. You will need to point your debugging instance to a SQL Server install that supports FILESTREAM. See &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/ssdt/thread/ceeaf961-fe8e-430a-99b7-c83ff9de77c3"&gt;this forum post&lt;/a&gt; for more details.&lt;/li&gt; &lt;ul&gt; &lt;li&gt;Set this in the Project Properties and point to an actual instance of SQL Server that supports the feature(s) you want to use.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;SQL Projects will substitute CONVERT for CAST in computed columns at the time of this writing. They also push default constraints with extra parentheses around the default value. If you clean these up from the target server, be aware that on your next Publish action, you could end up with extra work being done to make your target database use those parentheses or the CONVERT function.&lt;/li&gt; &lt;ul&gt; &lt;li&gt;To work around this, do a SQL Schema compare after a release to find any areas where the schema on the server differs from that in the project. For instance you may see a DEFAULT (getdate()) in your server, but have DEFAULT getdate() in your project.&amp;nbsp; Add the parentheses to your project to avoid unnecessary changes.&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Do you have any tips to share? Add them to the comments below.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/_wSx48V2rak" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/_wSx48V2rak/ssdt-tips-tricks-and-gotchas.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>2</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/11/ssdt-tips-tricks-and-gotchas.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-7987741733620251005</guid><pubDate>Fri, 09 Nov 2012 13:00:00 +0000</pubDate><atom:updated>2012-11-09T07:00:11.231-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: SQL Project Snapshots</title><description>SSDT allows for snapshots to be taken of the project at any point. Just right-click the project name and select the option to "Snapshot Project". &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href="http://lh5.ggpht.com/-q6ktXQ3Qrfc/UI8N5NLR1mI/AAAAAAAAHPA/F1AK3qj7wq0/s1600-h/clip_image001%25255B4%25255D.png"&gt;&lt;img alt="clip_image001" border="0" height="71" src="http://lh3.ggpht.com/-L7Z8r8X7S4I/UI8N5lmRhgI/AAAAAAAAHPI/KBIIF9vGm28/clip_image001_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="269" /&gt;&lt;/a&gt;&lt;/blockquote&gt;
This builds a dacpac file into a folder within the project called "Snapshots" with a default name format of Projectname_yyyymmdd_hh-mi-ss.dacpac. &lt;br /&gt;
This file contains a build of the project at the time the snapshot was taken, including all objects and scripts. &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Uses&lt;/b&gt; (by no means a complete list) &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Save a specific version of your project to use for release &lt;/li&gt;
&lt;li&gt;Save this version of the project before making changes to the underlying project &lt;/li&gt;
&lt;li&gt;Use as a source for schema compare &lt;/li&gt;
&lt;li&gt;See the differences between snapshots and/or the current project through schema compare &lt;/li&gt;
&lt;li&gt;Baseline your project &lt;/li&gt;
&lt;li&gt;Roll back to this state &lt;ul&gt;
&lt;li&gt;Schema Compare with the snapshot as the source and the Project as the target &lt;/li&gt;
&lt;li&gt;Import into a new project with this as the source. &lt;/li&gt;
&lt;li&gt;Import into current project, but be aware that this could easily produce a lot of duplicates&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/JsB6b4kMjmI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/JsB6b4kMjmI/ssdt-sql-project-snapshots.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-L7Z8r8X7S4I/UI8N5lmRhgI/AAAAAAAAHPI/KBIIF9vGm28/s72-c/clip_image001_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/11/ssdt-sql-project-snapshots.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-1540167057764601703</guid><pubDate>Thu, 08 Nov 2012 13:00:00 +0000</pubDate><atom:updated>2012-11-08T07:00:05.136-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SSIS</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Publishing Your Project</title><description>&lt;p&gt;Build the project &lt;p&gt;In order to successfully publish your project, it must first be able to build successfully. &lt;p&gt;Start by building your project. Right-click the project and select "Build". &lt;blockquote&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-gxESRmZUK_I/UI8Nj9msMII/AAAAAAAAHOA/99Q0i0vGvtk/s1600-h/clip_image001%25255B4%25255D.png"&gt;&lt;img title="clip_image001" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image001" src="http://lh6.ggpht.com/-fr4hxyo7C0M/UI8NkdCtCRI/AAAAAAAAHOI/fFxh34lGwls/clip_image001_thumb%25255B1%25255D.png?imgmax=800" width="359" height="174"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;If the build is successful, the project can be published. &lt;p&gt;&amp;nbsp; &lt;p&gt;You may want to create a folder within your project to store saved Publish Profiles. These can be used later to easily publish the project to your servers. &lt;blockquote&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-zDeO0kLf6XU/UI8NlK_tZzI/AAAAAAAAHOQ/kYAAEvH9_Dk/s1600-h/clip_image002%25255B5%25255D.png"&gt;&lt;img title="clip_image002" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image002" src="http://lh3.ggpht.com/-gzH7tdhqIfI/UI8NlprJr9I/AAAAAAAAHOY/gnRDDOhzu-w/clip_image002_thumb%25255B2%25255D.png?imgmax=800" width="612" height="411"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Creating Publish Profiles&lt;/strong&gt; &lt;p&gt;Right-click the project and select Publish. This will bring up the Publish Database dialog. &lt;ul&gt; &lt;li&gt;Choosing to publish or opening a saved publish profile will initiate a build of the project.&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-qI-8170byac/UI8NmSYpoDI/AAAAAAAAHOg/cx145N2Kp5Q/s1600-h/clip_image003%25255B4%25255D.png"&gt;&lt;img title="clip_image003" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image003" src="http://lh6.ggpht.com/-oODKcgYmRbE/UI8NnCfCZ7I/AAAAAAAAHOo/JJuVVD8IT6I/clip_image003_thumb%25255B1%25255D.png?imgmax=800" width="597" height="298"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Choose your target database, set your advanced options (similar to Schema Compare options), and choose the "Save Profile As" option to save this to a location within your project. Selecting the "Add profile to project" option will create the publish profile in the root of the project. You may wish to either move the file to a folder storing all of your publish profiles or, if you saved it without adding to the project, show all files of the project so you can include the file in the project. &lt;blockquote&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-HLRJgwoRlSw/UI8NnoTV3wI/AAAAAAAAHOw/Eh_hR5loPmY/s1600-h/clip_image004%25255B4%25255D.png"&gt;&lt;img title="clip_image004" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image004" src="http://lh3.ggpht.com/-OzBGvNsTr_Y/UI8NoEMfdUI/AAAAAAAAHO4/aersa4cJbXY/clip_image004_thumb%25255B1%25255D.png?imgmax=800" width="600" height="449"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&amp;nbsp; &lt;p&gt;Some options you may want to consider: &lt;ul&gt; &lt;li&gt;"Always re-create database" - this will re-create the database. Any data in the database will be lost. &lt;li&gt;"Block incremental deployment if data loss might occur" - If there are any changes that could result in the publish action failing because of data loss, this option will stop the script from running. &lt;li&gt;"DROP objects in target but not in project" - This will remove anything in the database that doesn't exist in the project. Useful if you want consistency, but you may want to ensure this isn't checked if there could be objects in the database that were created, but didn't make it to the project.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Under the "Advanced Deployment Options" &lt;ul&gt; &lt;li&gt;Allow Incompatible Platform - Useful if you may publish to a different version of SQL Server than the one specified in the project &lt;li&gt;Include transactional scripts - Will run the entire update operation as a transaction. If any one part fails, the transaction will roll back. If you have cross-database dependencies, selecting this option could result in no changes being published if you're publishing to a new server. For a new publication, you may want to de-select this option to ensure a successful deploy of what can be published. &lt;li&gt;Script state checks - This option will ensure that the publish action will only work on the specified server and database. &lt;li&gt;Verify deployment - Checks the database and project before publishing to try to ensure there are no changes that will cause problems with the publication such as missing data for a foreign key.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Using Publish Profiles&lt;/strong&gt; &lt;p&gt;Once you've set up your publish profiles, you can easily use these to push changes to that server and database without needing to specify additional parameters. The easiest way to use them is to double-click the Publish Profile within the project and choose to either "Generate Script" or "Publish". &lt;p&gt;Generate Script will generate a script for you to use to update the target at a later time (run in SQLCMD mode). &lt;p&gt;Publish will immediately attempt to push the changes to the target. &lt;p&gt;You can also use these at a later point to push changes through the SQLPackage.exe command line. &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;SQLPackage&lt;/strong&gt; &lt;p&gt;To publish your package through a command line we use something like the following:&lt;/p&gt; &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9d6225ea-5533-4f14-806a-e97bf8bb9e0a" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;sqlpackage /a:publish /sf:.&amp;#92;sql&amp;#92;Local&amp;#92;Adventureworks2008.dacpac /pr:.&amp;#92;Publish&amp;#92;Local.publish.xml&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The above will: &lt;ul&gt; &lt;li&gt;Use the "Publish" Action &lt;li&gt;Use the Source File named Adventureworks2008.dacpac, built in the sql\Local folder &lt;li&gt;Use the publish profile named "Local.publish.xml" (defined to push to the local SQL Server)&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;You may want to add SQLPackage.exe to your path. By default it is installed in: &lt;p&gt;C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin &lt;p&gt;You can override quite a few of the default settings through various command line arguments. This includes source, target, and variables. You can find a full list of the command line arguments at the &lt;a href="http://msdn.microsoft.com/en-us/library/hh550080%28v=VS.103%29.aspx"&gt;SQL Package reference online&lt;/a&gt;. &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Jenkins Automation for CI&lt;/strong&gt; &lt;p&gt;We use Jenkins at my current workplace and set up a Jenkins job to do the following (With thanks to Matthew Sneeden for the assistance.): &lt;ul&gt; &lt;li&gt;Get the latest from our mainline repository &lt;li&gt;Build each SQLProj file. &lt;ul&gt; &lt;li&gt;Building the SLN file will result in also attempting to publish the database &lt;li&gt;msbuild .\Adventureworks.sqlproj /t:build /p:Configuration="Local" &lt;ul&gt; &lt;li&gt;This assumes that msbuild.exe is in your path.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;Configuration is mostly to control the location of the dacpac file generated.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;Run SQLPackage w/ a specified Publish Profile for the appropriate environment and using the newly built dacpac as the source.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;We are currently investigating how we can use Snapshot files to better control releases to our UAT and Production environments. This series will be updated when that information is available.&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/7wj7IlhvOR4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/7wj7IlhvOR4/ssdt-publishing-your-project.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-fr4hxyo7C0M/UI8NkdCtCRI/AAAAAAAAHOI/fFxh34lGwls/s72-c/clip_image001_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/11/ssdt-publishing-your-project.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-717804800206975463</guid><pubDate>Wed, 07 Nov 2012 13:00:00 +0000</pubDate><atom:updated>2012-11-07T07:00:13.951-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Errors and Warnings</title><description>&lt;p&gt;SSDT includes an Errors and Warnings window that is well worth your attention. Ideally, your project should have no errors or warnings. &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-aA74AUYq8mI/UI8L9vMF9-I/AAAAAAAAHNQ/2biL_VfIki4/s1600-h/clip_image001%25255B5%25255D.png"&gt;&lt;img title="clip_image001" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image001" src="http://lh6.ggpht.com/-mkh7AJrY7Yk/UI8L-FO-VWI/AAAAAAAAHNY/yV72ua7lW9s/clip_image001_thumb%25255B2%25255D.png?imgmax=800" width="307" height="123"&gt;&lt;/a&gt; &lt;p&gt;&amp;nbsp; &lt;p&gt;However, sometimes coding errors slip in to your project or you get warnings that an object can't be found because it exists in another database. Sometimes a warning might appear because an object is missing completely, in this project or another one. In these cases, it's well worth checking this section to find out where you may have some issues. &lt;p&gt;Warnings are not necessarily a problem. SSDT will bring possible issues to your attention, but warnings will not stop a project from building and publishing unless you have set the option to treat warnings as errors or unless there really is an underlying problem that causes an issue during the publish phase. &lt;p&gt;For example, if I modify the Person.Address table to add a new column in the code, but forget to add a comma, I'll get an error something like this. &lt;blockquote&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-0wpAvtBOY34/UI8L-4rJ-ZI/AAAAAAAAHNg/g0bfKXlfIZM/s1600-h/clip_image002%25255B4%25255D.png"&gt;&lt;img title="clip_image002" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image002" src="http://lh5.ggpht.com/-0v9qV7UqFI0/UI8L_lvzdlI/AAAAAAAAHNo/-UtyE_bNFWg/clip_image002_thumb%25255B1%25255D.png?imgmax=800" width="1041" height="198"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;If you double-click on the line, the editor should open the appropriate file and take you pretty close to your problematic line. Correct the problem, save the file, and move on to the next error. &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Some common warnings/errors&lt;/strong&gt; &lt;ul&gt; &lt;li&gt;4151 - Unresolved database reference. This is often caused when one of the objects in a database references another. This can often be resolved by creating a database reference. &lt;li&gt;71562 - Unresolved database reference warning. &lt;li&gt;71502 - Another unresolved database reference warning.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;How to globally suppress certain warnings&lt;/strong&gt; &lt;ul&gt; &lt;li&gt;Right click the root of the project and select properties &lt;li&gt;Click on the "Build" tab &lt;li&gt;Enter in the numeric portion of the codes, separated by commas. Remove the "SQL" and any leading zeroes when entering the code.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-W-7ZFT7Kc_Q/UI8MAcoJivI/AAAAAAAAHNw/QTW39IllJRQ/s1600-h/clip_image003%25255B5%25255D.png"&gt;&lt;img title="clip_image003" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image003" src="http://lh5.ggpht.com/-1j1fh72KzAI/UI8MA9pemXI/AAAAAAAAHN4/jsRSfS8E8HE/clip_image003_thumb%25255B2%25255D.png?imgmax=800" width="725" height="296"&gt;&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/7mYtVYVg7EQ" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/7mYtVYVg7EQ/ssdt-errors-and-warnings.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-mkh7AJrY7Yk/UI8L-FO-VWI/AAAAAAAAHNY/yV72ua7lW9s/s72-c/clip_image001_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/11/ssdt-errors-and-warnings.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-3156469736001094828</guid><pubDate>Tue, 06 Nov 2012 13:00:00 +0000</pubDate><atom:updated>2012-11-06T07:00:13.615-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Updating a Project Manually</title><description>Sometimes it's necessary to modify the project manually. The change might require specific tweaking to include just a couple of new lines in a stored procedure or function. It might be just adding a column to a table. Maybe you know exactly what change needs to be made and would rather just edit it manually instead of comparing or importing. Whatever the reason, updating your project manually can be done without too much trouble. &lt;br /&gt;
If you know the name and location of the file you want to edit, just go straight to it and right-click it. &lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/-4GwYAkDUM_Q/UI8LPNqJJGI/AAAAAAAAHMA/K0Apjqyxdc0/s1600-h/clip_image001%25255B3%25255D.png"&gt;&lt;img alt="clip_image001" border="0" height="151" src="http://lh6.ggpht.com/-ZgLa9ncQ-Xk/UI8LP1n_UtI/AAAAAAAAHMI/bw2KUjiMKnQ/clip_image001_thumb.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="244" /&gt;&lt;/a&gt; &lt;br /&gt;
You have two ways to edit the file - using "View Code" will bring up a T-SQL script. Edit as you would any other T-SQL script and save. Remember that SSDT scripts create all base objects using CREATE scripts. &lt;br /&gt;
If you choose to View Designer, you'll see a new screen combining a design view with a T-SQL editor. &lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/-7tLuHYP1pPg/UI8LQiGPOSI/AAAAAAAAHMQ/vKxOV_bwBX8/s1600-h/clip_image002%25255B5%25255D.png"&gt;&lt;img alt="clip_image002" border="0" height="527" src="http://lh6.ggpht.com/-A-FSMMv963M/UI8LRN82KRI/AAAAAAAAHMY/lxfay7NGsac/clip_image002_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image002" width="622" /&gt;&lt;/a&gt; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
Here you can choose to edit within either window. The code will be kept in sync across the panels. You can right-click any of the Keys, Indexes, Triggers, Constraints in the upper window and choose to add a new one. You'll get a shell of the script to create a new object tied to this table. Modify its code to match what you want to do and save the file. &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;This is different behavior from the older Database Projects. Those would create separate files for each object by default. In SSDT, the scripts are all put together in one script unless you upgraded from a DB Project. &lt;/li&gt;
&lt;li&gt;The only place SSDT supports "GO" to break up the batches is within these create scripts. You cannot use GO in a post or pre deploy script. &lt;/li&gt;
&lt;li&gt;If you highlight a column in the table, you can give it a description in the Properties window. This is an easy way to propagate object/column descriptions into your SQL Server. &lt;/li&gt;
&lt;li&gt;You can select the table's properties in the Properties window dropdown to edit its properties/description.&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://lh3.ggpht.com/-AQN3-jrP9dQ/UI8LRw1wDbI/AAAAAAAAHMg/i7GIPd4ZRRA/s1600-h/clip_image003%25255B4%25255D.png"&gt;&lt;img alt="clip_image003" border="0" height="285" src="http://lh6.ggpht.com/-nGbXiLurw9s/UI8LSR8NCtI/AAAAAAAAHMo/cCskrKqgBA4/clip_image003_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image003" width="396" /&gt;&lt;/a&gt; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;SQL Server Object Explorer&lt;/b&gt; &lt;br /&gt;
If you hit the F5 key inside of a project to debug the project, SSDT will build a local database, often hosted in an instance called (localdb)\Databasename. This will run the database project in a debug session. If you then open the SQL Server Object Explorer view, you can edit the project and underlying scripts. &lt;br /&gt;
&lt;blockquote&gt;
This works in most instances where you’re using basic SQL Server functionality. If you’re using any more advanced features such as Filestream, you’ll want to change the location for this debug instance. You can change these in the project properties.&lt;/blockquote&gt;
&lt;a href="http://lh6.ggpht.com/-YAneNhj4QxQ/UI8LS-ELP2I/AAAAAAAAHMw/k8LuDWNwRl0/s1600-h/clip_image004%25255B4%25255D.png"&gt;&lt;img alt="clip_image004" border="0" height="441" src="http://lh6.ggpht.com/-lPmjsNfvoAY/UI8LTrC08EI/AAAAAAAAHM4/6DLHJ3HD8gM/clip_image004_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image004" width="468" /&gt;&lt;/a&gt;&lt;br /&gt;
 &lt;br /&gt;
 Double-clicking the HumanResources.EmployeePayHistory table above brings up the editor for the underlying table in the project. &lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/-B6Dzd5mOkyI/UI8LUdmoRpI/AAAAAAAAHNA/HMKlPeYPdcg/s1600-h/clip_image005%25255B5%25255D.png"&gt;&lt;img alt="clip_image005" border="0" height="355" src="http://lh4.ggpht.com/-JZCmTfHE-nw/UI8LVNSo1-I/AAAAAAAAHNI/Nx2rilL1x-o/clip_image005_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image005" width="606" /&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;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/CQ4v5XZDOag" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/CQ4v5XZDOag/ssdt-updating-project-manually.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-ZgLa9ncQ-Xk/UI8LP1n_UtI/AAAAAAAAHMI/bw2KUjiMKnQ/s72-c/clip_image001_thumb.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/11/ssdt-updating-project-manually.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-4179391197138101524</guid><pubDate>Mon, 05 Nov 2012 13:00:00 +0000</pubDate><atom:updated>2012-11-05T07:00:06.442-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Updating a Project by Importing Scripts</title><description>Sometimes your developers will work on new SQL Objects and give you scripts to alter or create objects. SQL Projects support importing those scripts into your project. Start by choosing the Import Script option. &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href="http://lh5.ggpht.com/-nIiEHj07IDk/UI8KVXowu5I/AAAAAAAAHLQ/B4MAhs_ADHI/s1600-h/clip_image001%25255B5%25255D.png"&gt;&lt;img alt="clip_image001" border="0" height="87" src="http://lh4.ggpht.com/-x0k0gA8bjmY/UI8KV8GNZII/AAAAAAAAHLY/XOcBI4XUH-w/clip_image001_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="610" /&gt;&lt;/a&gt;&lt;/blockquote&gt;
Find your script or scripts. &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href="http://lh6.ggpht.com/-g4pZuzG7ztw/UI8KWTDZBZI/AAAAAAAAHLg/Afj8tc8vy28/s1600-h/clip_image002%25255B5%25255D.png"&gt;&lt;img alt="clip_image002" border="0" height="520" src="http://lh6.ggpht.com/-9CFEgRUnF6I/UI8KXFt-20I/AAAAAAAAHLo/_iVHCwK5Kx8/clip_image002_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image002" width="611" /&gt;&lt;/a&gt;&lt;/blockquote&gt;
Select your options for import: &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href="http://lh3.ggpht.com/-6PW5x6XXL90/UI8KXgLFhII/AAAAAAAAHLw/bghlku595mY/s1600-h/clip_image003%25255B4%25255D.png"&gt;&lt;img alt="clip_image003" border="0" height="102" src="http://lh5.ggpht.com/-94zhikdKDiE/UI8KYVAAfqI/AAAAAAAAHL4/fNT19kNB4Ik/clip_image003_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image003" width="696" /&gt;&lt;/a&gt;&lt;/blockquote&gt;
&amp;nbsp; &lt;br /&gt;
If you see the following text in your log, be sure to check this file to see if something was missed on import. You'll need to manually make these changes, if applicable. In a lot of cases, the statements not understood tend to be "GO" statements. &lt;br /&gt;
&lt;blockquote&gt;
“In the script that you provided to the import operation, one or more statements were not fully understood. These statements were moved to the ScriptsIgnoredOnImport.sql file. Review the file contents for additional information.”&lt;/blockquote&gt;
I've also found that "ALTER TABLE" statements are not well understood by SSDT within the imported scripts. If you get several scripts that include these and aren't understood, you can either compare the physical database to the project or manually update the project. (This has been acknowledged by Microsoft as “working as designed” even if we might wish that this could actually change the script for the object instead.)   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/dZlQyhJnNn0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/dZlQyhJnNn0/ssdt-updating-project-by-importing.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-x0k0gA8bjmY/UI8KV8GNZII/AAAAAAAAHLY/XOcBI4XUH-w/s72-c/clip_image001_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/11/ssdt-updating-project-by-importing.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-2013391766563367783</guid><pubDate>Fri, 02 Nov 2012 13:00:00 +0000</pubDate><atom:updated>2012-11-02T08:00:06.831-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Updating by Using Schema Compare</title><description>Sometimes changes are made to a shared database that need to be brought into your SQL Project and there are no saved change scripts for those changes. Other times you may just want to see what will change when you publish a project. SSDT has included a Schema Compare option for SQL Projects, dacpac files, and databases. &lt;br /&gt;
If you are using VS2010, there are two options for SQL and Data. &lt;br /&gt;
&lt;a href="http://lh4.ggpht.com/-Iu18Q_89iWY/UI8JkJNYEeI/AAAAAAAAHKA/F_ao-1Y64Bk/s1600-h/clip_image001%25255B3%25255D.png"&gt;&lt;img alt="clip_image001" border="0" height="25" src="http://lh5.ggpht.com/-LcqSQG-K0WM/UI8Jk18utcI/AAAAAAAAHKI/ZC6pQ58iwkI/clip_image001_thumb.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="79" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The "Data" menu is used for the older DB Projects within VS2010. There's a useful data compare option in there, but the schema compare will not work for SQL 2012 or SQL Projects. &lt;/li&gt;
&lt;li&gt;The "SQL" menu contains the Schema Compare item with a sub-item to do a new Schema Comparison&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;a href="http://lh5.ggpht.com/-EdgXyHsQY7E/UI8JlXsI3mI/AAAAAAAAHKQ/NFG4VUC4now/s1600-h/clip_image002%25255B4%25255D.png"&gt;&lt;img alt="clip_image002" border="0" height="108" src="http://lh3.ggpht.com/-Cjij6KMD3nE/UI8JmJxP4_I/AAAAAAAAHKY/0pJ0lH9Wuuo/clip_image002_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image002" width="460" /&gt;&lt;/a&gt;&lt;/blockquote&gt;
To update your project from a shared database, start a "New Schema Comparison". You'll see a screen something like this: &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href="http://lh6.ggpht.com/-qJs_AU0aK9U/UI8Jmo4AvrI/AAAAAAAAHKg/lpr9cL2SHGs/s1600-h/clip_image003%25255B4%25255D.png"&gt;&lt;img alt="clip_image003" border="0" height="261" src="http://lh6.ggpht.com/-HUGGOpMK9z0/UI8JnCe2vUI/AAAAAAAAHKo/Q9N2BdSq8VA/clip_image003_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image003" width="482" /&gt;&lt;/a&gt;&lt;/blockquote&gt;
Setting your source/target is pretty straightforward and each will produce a screen something like the following: &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href="http://lh3.ggpht.com/-He9lLnRKIRY/UI8Jn6lAvUI/AAAAAAAAHKw/_Bbci4N6UIc/s1600-h/clip_image004%25255B4%25255D.png"&gt;&lt;img alt="clip_image004" border="0" height="337" src="http://lh6.ggpht.com/-tXUi6j_Qj4Y/UI8JoSL1a7I/AAAAAAAAHK4/xywuh4CM8A0/clip_image004_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image004" width="362" /&gt;&lt;/a&gt;&lt;/blockquote&gt;
You can choose to compare against an open project, a live database, or a Data-tier Application File (dacpac). In our case, we are going to select a live database as the source and our project as the target. &lt;br /&gt;
Once selected, you may want to change the options to exclude certain object types or ignore certain settings such as file placement. Unlike in VS2010, the options cannot be set to some default at this time. When you've set the options to your liking, click the "Compare" button. &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href="http://lh4.ggpht.com/-NoBJEXfI_sY/UI8JozvdY3I/AAAAAAAAHLA/CvWvz9KBHdM/s1600-h/clip_image005%25255B4%25255D.png"&gt;&lt;img alt="clip_image005" border="0" height="407" src="http://lh6.ggpht.com/-5uPEGnWEuys/UI8JpgPMejI/AAAAAAAAHLI/BOEH08fh4OY/clip_image005_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image005" width="474" /&gt;&lt;/a&gt;&lt;/blockquote&gt;
If there are any differences, you'll see a list of them here. The comparison window shows where there are differences between the source and target. This can be really helpful to know whether or not to include this change in the update. &lt;br /&gt;
To exclude a change, clear the checkbox next to it in the upper section of the window. A green + indicates that this object will be created. A red - indicates that the object will be dropped. The blue pencil indicates that the object will be modified. At this time there is no way to hide any unchecked items that show in the compare. &lt;br /&gt;
Once you're satisfied with your selection, click the "Update" button to push those changes into your project.   &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;img src="http://feeds.feedburner.com/~r/SchottSql/~4/7yZXG9i0S7o" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/7yZXG9i0S7o/ssdt-updating-by-using-schema-compare.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-LcqSQG-K0WM/UI8Jk18utcI/AAAAAAAAHKI/ZC6pQ58iwkI/s72-c/clip_image001_thumb.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/11/ssdt-updating-by-using-schema-compare.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-4773880027663834590</guid><pubDate>Thu, 01 Nov 2012 13:00:00 +0000</pubDate><atom:updated>2012-11-01T08:00:07.060-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Pre and Post Deploy Scripts</title><description>At some point, you will likely need to release changes that contain more than just schema changes. You may need to update data in a table, remove data that could cause a problem, or insert some data to support a code release. To support these changes, SSDT provides support for Pre-Deploy and Post-Deploy scripts.  &lt;br /&gt;
These scripts are not created by default in a new SSDT project. To organize your scripts, you may want to create a folder structure similar to the following.  &lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/-HOOcY5-tIH0/UIseD_7wNgI/AAAAAAAAHJE/7hKAdcYnwO4/s1600-h/clip_image001%25255B5%25255D.png"&gt;&lt;img alt="clip_image001" border="0" height="123" src="http://lh3.ggpht.com/-cfvPyPgxE6g/UIseEaui0GI/AAAAAAAAHJM/ppZazOPfp1Q/clip_image001_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="305" /&gt;&lt;/a&gt;  &lt;br /&gt;
If you right-click the Post or Pre Deploy folders, you can choose to add a Script item.  &lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/-P44ofwtLC4E/UIseE31n3pI/AAAAAAAAHJU/dImVLxZOh0o/s1600-h/clip_image002%25255B4%25255D.png"&gt;&lt;img alt="clip_image002" border="0" height="249" src="http://lh4.ggpht.com/-JKlhF_POeSQ/UIseFp7-eZI/AAAAAAAAHJc/51kX6pwJbP0/clip_image002_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image002" width="609" /&gt;&lt;/a&gt;  &lt;br /&gt;
You will then get a choice of which type of script to include. Choose Pre or Post deployment, as appropriate, and name the file accordingly.  &lt;br /&gt;
&lt;blockquote&gt;
&lt;b&gt;You can only have one Pre-Deployment script and one Post-Deployment script per project as part of the Build! All included scripts must be set to “Not in build” or you will likely have errors.&lt;/b&gt;&lt;/blockquote&gt;
&lt;a href="http://lh3.ggpht.com/-Vp_lnZ0eOlE/UIseGI5fmjI/AAAAAAAAHJk/C_1QfK1S1Vw/s1600-h/clip_image003%25255B4%25255D.png"&gt;&lt;img alt="clip_image003" border="0" height="181" src="http://lh5.ggpht.com/-CVle1GWMwbE/UIseGj3fXfI/AAAAAAAAHJs/6agqlulXaGU/clip_image003_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image003" width="509" /&gt;&lt;/a&gt; &lt;br /&gt;
 If you look at the properties of these scripts, you will see that the Build Action is set to PreDeploy or PostDeploy. Opening the Post-Deploy script will show this default text.&lt;br /&gt;
&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; height: 197px; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 623px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;/*
Post-Deployment Script Template       
--------------------------------------------------------------------------------------&amp;nbsp; This file contains SQL statements that will be appended to the build script.&amp;nbsp; Use SQLCMD syntax to include a file in the post-deployment script.&amp;nbsp; Example:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :r .\myfile.sql&amp;nbsp; Use SQLCMD syntax to reference a variable in the post-deployment script.&amp;nbsp; Example:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :setvar TableName MyTable&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT * FROM [$(TableName)]     
--------------------------------------------------------------------------------------
*/&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;br /&gt;&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Using Pre and Post Deploy Scripts &lt;/b&gt;&lt;br /&gt;
These files are interpreted as SQLCMD scripts by SSDT. You can use most valid SQLCMD syntax within the script file to include other scripts and set variables. At the time of this writing, you cannot use the&lt;b&gt; :ON ERROR IGNORE&lt;/b&gt; command within a script. This will hopefully be addressed in a future release of SSDT.&lt;br /&gt;
Pre-Deploy scripts will always run before the schema changes are run. If you alter the database in a way that changes the schema, you may encounter errors with the release. E.g., if you make schema changes to the Person.Person table, but drop that table in a Pre-Deploy script, your publish action will likely fail. &lt;br /&gt;
Likewise, Post-Deploy scripts will always run after the publish action. This makes them a great place to insert new data, make small adjustments to the system, or perhaps implement custom security and permissions. The caveat to using post-deploy scripts to make changes is that the changes need to be repeatable. If you write an insert statement for a new lookup value, that same insert will run next time unless you check for the existing value first. &lt;br /&gt;
To create a new script to run in pre or post deploy: &lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;Right-click the appropriate folder (Pre-Deploy, Post-Deploy, other) &lt;/li&gt;
&lt;li&gt;Choose to add a "script" and select the "Script (Not in build)" option &lt;/li&gt;
&lt;li&gt;Give it a name, preferably one without spaces as it will make it easier to run the pre or post deploy script. &lt;/li&gt;
&lt;li&gt;Add your code changes. You may want to give it some descriptive comments and sometimes a Print statement can be helpful if you want to see progress as you run a deploy script manually. &lt;br /&gt;&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;Make sure that you can re-run this script without causing errors! Check for data that may already exist, use outer joins, wrap your code in Try/Catch - whatever you need to do to make sure that you can have this run again if necessary.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;After saving the script, edit your pre or post-deploy script and add a new line in a non-commented area something like:&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d779d1cd-8e11-4de1-9813-80c5c0768bbf" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;br /&gt;
&lt;div style="border: #000080 1px solid; color: black; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;br /&gt;
&lt;div style="background: #000080; color: white; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;
Run a script called "MyScript"&lt;/div&gt;
&lt;br /&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto;"&gt;
&lt;br /&gt;
&lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt;&lt;br /&gt;
&lt;li&gt;:r .\MyScript.sql&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;This assumes that your script is in the same folder as your pre or post-deploy scripts. Adjust the relative paths as needed for the script you created.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;li&gt;Save your deploy script.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;The next time you publish your project, it will pick up this script and include it in your change set. If you choose to create a script on publish, you can see the full text of your scripts included in the pre or post-deploy section of your change script. &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Cleanup of Pre and Post Deploy Scripts&lt;/b&gt;&lt;br /&gt;
There are several options for cleanup, but one of the best suggestions I've seen has been to generate project snapshots and then remove the script references from your pre/post deploy scripts and the script files themselves from the project. They will still be saved in the snapshot, but will not be in your project anymore.&amp;nbsp; You may be able to manage this well through your Version Control System, but snapshots do have some advantages.&lt;br /&gt;
Pros: &lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;Your project will remain somewhat clean. &lt;/li&gt;
&lt;li&gt;Script files will be saved with their appropriate snapshot, ideally tied to a particular release. &lt;/li&gt;
&lt;li&gt;Less concern about whether a script is replayed because it's removed. &lt;/li&gt;
&lt;li&gt;Good for scripts that have a larger impact and should only be run one-time.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;Cons: &lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;It's a manual process and requires some attention to detail. &lt;/li&gt;
&lt;li&gt;You need to look in the snapshots to see what scripts were used. &lt;/li&gt;
&lt;li&gt;It may require that you have a more formalized release process. &lt;/li&gt;
&lt;li&gt;You may need to publish several snapshots to bring the database up to a current version.&lt;/li&gt;
&lt;/ul&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;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/UX6nGFdz4a0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/UX6nGFdz4a0/ssdt-pre-and-post-deploy-scripts.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-cfvPyPgxE6g/UIseEaui0GI/AAAAAAAAHJM/ppZazOPfp1Q/s72-c/clip_image001_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/11/ssdt-pre-and-post-deploy-scripts.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-2844089478563710720</guid><pubDate>Wed, 31 Oct 2012 13:00:00 +0000</pubDate><atom:updated>2012-10-31T08:00:09.032-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: External Database References</title><description>If your database references other databases, you'll need a *.dacpac file for each external database referenced in your code. For example, if you reference AdventureWorksDW2008 from Adventureworks2008, you'll need to add that as a database reference. &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;To add a Database Reference to your project&lt;/b&gt; &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Right-click the "References" folder in your project or choose the "Project" menu and select the option to "Add Database Reference"&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;a href="http://lh3.ggpht.com/-IOueQFm1Plk/UIsa6pPFoxI/AAAAAAAAHIY/2q6VREVZTRU/s1600-h/clip_image001%25255B4%25255D.png"&gt;&lt;img alt="clip_image001" border="0" height="71" src="http://lh6.ggpht.com/-YjDmwFoabxc/UIsa7A7GgNI/AAAAAAAAHIg/Y3U6g03XHlA/clip_image001_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="339" /&gt;&lt;/a&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Browse for your dacpac file &lt;/li&gt;
&lt;li&gt;Choose the appropriate database location. (Same, Different DB / Same Server, or Different DB / Different Server) &lt;/li&gt;
&lt;li&gt;If your database name doesn't change, clear out the "Database Variable" column. It isn't immediately obvious, but doing this will let you keep referencing your database in the same manner you do currently. &lt;ul&gt;
&lt;li&gt;If this database name can vary, populate the Database Variable field. You'll need to replace this reference in your code with the variable from this column. &lt;/li&gt;
&lt;li&gt;If you're referencing a database on a linked server, this would probably be better served with a static database name and a "Server Variable". Make sure that server variable is set appropriately when you publish the database.&lt;/li&gt;
&lt;li&gt;This should be addressed with a future release of SSDT.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;You may choose to suppress errors if there are unresolved references in the project. This is useful if your dacpac file could be out of date. You can still code against an object you know to exist, but isn't in the reference file yet.&lt;/li&gt;
&lt;li&gt;If you use Linked Servers, you’ll probably want to use the Server Variable to ensure that you can release your code in different environments.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;a href="http://lh6.ggpht.com/-jqbPkInFVFw/UIsa7zNvprI/AAAAAAAAHIo/-TL_WgevOx8/s1600-h/clip_image002%25255B5%25255D.png"&gt;&lt;img alt="clip_image002" border="0" height="482" src="http://lh3.ggpht.com/-3zN8Y_LLfMI/UIsa8epmsxI/AAAAAAAAHIw/3BUwPcc9z_c/clip_image002_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image002" width="695" /&gt;&lt;/a&gt;&lt;/blockquote&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Some Best Practices and Lessons Learned&lt;/b&gt; &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Make a shared folder to store your dacpac files in a common place. This should be easily accessible from all of your SQL Projects. &lt;ul&gt;
&lt;li&gt;If you use C:\DatabaseProjects as your base for all SQL Server projects, create a folder in there to store your shared dacpac files.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Because all paths are relative to the project, you &lt;i&gt;may&lt;/i&gt; need to copy the master/msdb dacpac files that ship with SSDT into your shared folder. You can find these files in your Visual Studio folder in a path similar to the following.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;i&gt;Drive&lt;/i&gt;:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\SQLDB\Extensions\SqlServer\VersionNumber\SqlSchemas&lt;/blockquote&gt;
&lt;ul&gt; &lt;ul&gt;
&lt;li&gt;If you support multiple SQL Server editions, you may want to rename master/msdb files with their user-friendly version number. E.g., the master.dacpac file in your "90" folder could be renamed to master2005.dacpac&lt;/li&gt;
&lt;li&gt;This should be addressed in a future release of SSDT and could already be fixed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;br /&gt;
 &lt;ul&gt;
&lt;li&gt;If you use variables, don’t forget to replace any TSQL with the variable in the form of &lt;i&gt;[$(VariableName)]&lt;/i&gt;.&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Square braces may not be necessary, but in most cases, they’ll work as expected for DB or Server names.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;If you need to reference a dacpac that is already in use, you’ll need to create a copy of it. This comes up more often if you’re referencing a replicated database for which you already have a production dacpac.&lt;/li&gt;
&lt;li&gt;Choose good variable names for the Server variable name.&lt;/li&gt;
&lt;li&gt;Don’t forget to set the variables in the Project and/or Publication properties!&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/IUmwNVdGHa0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/IUmwNVdGHa0/ssdt-external-database-references.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-YjDmwFoabxc/UIsa7A7GgNI/AAAAAAAAHIg/Y3U6g03XHlA/s72-c/clip_image001_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/10/ssdt-external-database-references.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-2665614276023424614</guid><pubDate>Tue, 30 Oct 2012 13:00:00 +0000</pubDate><atom:updated>2012-10-30T08:00:09.173-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: SQL Project Options</title><description>To set the properties for your SQL Project, right-click the Project and select Properties. You'll see a window containing several tabs to define your project. &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Project Settings&lt;/b&gt; &lt;br /&gt;
Here you can set your normal target platform (SQL 2005, 2008, 2012, or Azure). &lt;br /&gt;
You can enable the T-SQL verification option, but this is mostly for Azure projects. &lt;br /&gt;
If you will generally output to a script, choose the "Create script" option. On the whole, just using the dacpac file will likely provide greater flexibility in the long run as it can be adapted to a different target. Generating a script will only be guaranteed to work against the target used to generate the script. &lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/-Y70G6sSeD2k/UIsW6gkodsI/AAAAAAAAHF8/FpIveBAKzWU/s1600-h/clip_image001%25255B9%25255D.png"&gt;&lt;img alt="clip_image001" border="0" height="433" src="http://lh4.ggpht.com/-E9TNLPRik4o/UIsW7NCsUoI/AAAAAAAAHGE/coE2a0DCu7E/clip_image001_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="686" /&gt;&lt;/a&gt; &lt;br /&gt;
You can also set the dacpac file properties, which sadly do not do much when used against a database not using these as data-tier applications. There is some talk of enhancing the projects to use this version number and description somewhere within the database, but right now they are pretty much only there for you to populate if you wish. &lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/-ba05AnMQ0I0/UIsW78GeuoI/AAAAAAAAHGM/F-42PCJ0RI4/s1600-h/clip_image002%25255B9%25255D.png"&gt;&lt;img alt="clip_image002" border="0" height="387" src="http://lh4.ggpht.com/-dJA4crWwEWI/UIsW8dYDchI/AAAAAAAAHGU/LEKMICxlmzQ/clip_image002_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image002" width="542" /&gt;&lt;/a&gt; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
You can also set the Database Settings for your project. These options are the normal ones you would set when setting options in SQL Server. You can choose to publish these to your targets so set these to your preferences. (More on that in a future post.) &lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/-vby1wExLUb4/UIsW8yUW_OI/AAAAAAAAHGc/nMCDnyrHaPA/s1600-h/clip_image003%25255B8%25255D.png"&gt;&lt;img alt="clip_image003" border="0" height="312" src="http://lh4.ggpht.com/-L0B74BedRvw/UIsW9UxPmdI/AAAAAAAAHGk/pO18caZqlRA/clip_image003_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image003" width="528" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;a href="http://lh4.ggpht.com/-HOA5cXbR1g4/UIsW9wDBvEI/AAAAAAAAHGs/S2EMQ5OHrxY/s1600-h/clip_image004%25255B8%25255D.png"&gt;&lt;img alt="clip_image004" border="0" height="518" src="http://lh4.ggpht.com/-iH8oQ93jAfQ/UIsW-me2mYI/AAAAAAAAHG0/b-5wma_2kzw/clip_image004_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image004" width="520" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/-L57kvOItDow/UIsW_cfeGcI/AAAAAAAAHG8/BuaiqG_ZWoc/s1600-h/clip_image005%25255B8%25255D.png"&gt;&lt;img alt="clip_image005" border="0" height="330" src="http://lh4.ggpht.com/-GGkK50Cl-dc/UIsW_4bVH-I/AAAAAAAAHHE/spUOCmPhSUg/clip_image005_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image005" width="526" /&gt;&lt;/a&gt; &lt;br /&gt;
I'm going to bypass the SQLCLR and SQLCLR Build tabs as I am not familiar with them and don’t currently use either in our system. &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Build&lt;/b&gt; &lt;br /&gt;
The Build tab is the place to specify which warnings to ignore, the output path for your files when you build the project, and the name of the file. You may want to specify certain warnings to ignore, especially if you use cross-database projects or any references to system databases. Those can often result in warnings about missing objects, even though they'll work perfectly fine when you publish them. &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Note that the warnings are set per configuration. If you use multiple configurations be sure to set the warnings in each one.&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://lh5.ggpht.com/-ewAmdhTvAp0/UIsXASfUlwI/AAAAAAAAHHM/xzvQy6EdH_k/s1600-h/clip_image006%25255B7%25255D.png"&gt;&lt;img alt="clip_image006" border="0" height="247" src="http://lh6.ggpht.com/-bSiZ6eGvNAk/UIsXA2fPA9I/AAAAAAAAHHU/gO2A_vRCbP4/clip_image006_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image006" width="601" /&gt;&lt;/a&gt; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/-kN6Hba2UpDc/UIsXBSc23OI/AAAAAAAAHHc/8idgxm3voO0/s1600-h/clip_image006%25255B1%25255D%25255B4%25255D.png"&gt;&lt;img alt="clip_image006[1]" border="0" height="249" src="http://lh5.ggpht.com/-8KLLzDTUm5Q/UIsXCbzQ1NI/AAAAAAAAHHk/6AXGgOVQsw4/clip_image006%25255B1%25255D_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image006[1]" width="602" /&gt;&lt;/a&gt; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;SQLCMD Variables&lt;/b&gt; &lt;br /&gt;
SQLCMD variables can be used throughout the project as placeholders for values passed in at publication time. For example, you may choose to change the way your scripts run based on your Development, Customer Acceptance, or Production environments. Define these variables here and use them wherever applicable in the project by inserting them as $(DeployType). SSDT will substitute them with the proper value on publication. &lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/-gPFv_yOSy1c/UIsXC9c3wvI/AAAAAAAAHHs/LMmWiHrPC-4/s1600-h/clip_image007%25255B5%25255D.png"&gt;&lt;img alt="clip_image007" border="0" height="186" src="http://lh5.ggpht.com/-DvqunmUsFyc/UIsXDcwcCVI/AAAAAAAAHH0/QWLkA8hI164/clip_image007_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image007" width="557" /&gt;&lt;/a&gt; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Build Events&lt;/b&gt; &lt;br /&gt;
Build events can be set up to run certain commands before and after the project is built. You can also choose to run the Post-Build event commands only when the project builds successfully or on every build. &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Debug&lt;/b&gt; &lt;br /&gt;
Start Action and Target Connection String should make sense for those who need to change them. One item to note is that the debug action defaults to a SQL Express type instance of your database that is released to (localhost)\DBName. This will run within SSDT so you can try out your T-SQL before committing the changes in the project. &lt;br /&gt;
** Note that if you use FILESTREAM, you will not be able to use these user instances. You will need to change your debug database to a SQL Server install. &lt;br /&gt;
In your Deployment Options, you have a screen that looks something like this: &lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/-NF3id_RSl-g/UIsXDy_yINI/AAAAAAAAHH8/6gmZZIvK52M/s1600-h/clip_image008%25255B5%25255D.png"&gt;&lt;img alt="clip_image008" border="0" height="260" src="http://lh6.ggpht.com/-S2jmvoMU9r0/UIsXEZm5sSI/AAAAAAAAHIE/wXJ0Ipm_sng/clip_image008_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image008" width="529" /&gt;&lt;/a&gt; &lt;br /&gt;
"Block incremental deployment" is one to be aware of. If you run into any constraints, refactoring, data type changes, NULL to NOT NULL, or similar changes, you could have your debug action stop unexpectedly. It can be really useful to avoid dropping columns that could contain data, but if you are aware of the changes, this option could also get in the way of normal releases. According to the MS documentation, this will only block the change if there is data in the table. &lt;br /&gt;
"DROP Objects in target but not in project" can be useful to make sure that everyone is running with what's in the project and that they don't have leftover objects that could interfere with testing. However, it's also possible to lose a bunch of work if you publish a project with this option against your local instance containing the stored procedure you've worked on for the last 2 weeks. &lt;br /&gt;
"Advanced" contains a lot of different options about what to compare and how to generate the changes. Some of the more interesting options include: &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Allow incompatible platform - this will let you push your changes to a version of SQL Server other than the one specified in the project properties. The changes will fail if you try to do something not allowed in the target, but useful in case you have your project set to the lowest version supported. &lt;/li&gt;
&lt;li&gt;"Drop xyz not in source" - these options control what will be dropped from the target if it's not defined in the source. The default options are likely good for most users. &lt;/li&gt;
&lt;li&gt;"Ignore xyz" - defines what should be ignored when comparing the project against the target. You may want to ignore details about the partition schemes, or what permissions are set in the target &lt;/li&gt;
&lt;li&gt;"Include Transactional Scripts" will set up the release script as transactions when publishing the database. This is useful when you want to make sure that if one part of the publish action fails, the change script is rolled back. &lt;/li&gt;
&lt;li&gt;"Verify Deployment" - stops the publish actions if the script could run into some problems.&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;&lt;/b&gt;&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Reference Paths&lt;/b&gt; &lt;br /&gt;
This section is used to modify and maintain the various Server &amp;amp; Database variables used with cross-database references. See the "External Database References" page for more detail. &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Code Analysis&lt;/b&gt; &lt;br /&gt;
This option can be useful to check for common issues such as using reserved words, non-standard characters in object names, or using "select *" in your queries. You can also specify whether to show these as errors or warnings. Set appropriately for your environment.   &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;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;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;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;img src="http://feeds.feedburner.com/~r/SchottSql/~4/KpJrQ1ncnSc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/KpJrQ1ncnSc/ssdt-sql-project-options.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-E9TNLPRik4o/UIsW7NCsUoI/AAAAAAAAHGE/coE2a0DCu7E/s72-c/clip_image001_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/10/ssdt-sql-project-options.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-3769573156450083838</guid><pubDate>Mon, 29 Oct 2012 13:00:00 +0000</pubDate><atom:updated>2012-10-29T08:00:05.793-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Importing an Existing Database</title><description>&lt;b&gt;To Import From an Existing Database&lt;/b&gt; &lt;br /&gt;
Import Database into your project by right-clicking the project name or selecting the Project Menu and selecting the Import -&amp;gt; Database option. Note that you can also import from SQL Scripts or an existing dacpac file. One of those may be necessary if you don't have direct access to your source server. &lt;br /&gt;
&lt;a href="http://lh4.ggpht.com/-BctSRFWVy6Y/UIsVnbxzrkI/AAAAAAAAHE8/K9vZlch84tw/s1600-h/clip_image001%25255B4%25255D.png"&gt;&lt;img alt="clip_image001" border="0" height="94" src="http://lh5.ggpht.com/-8S9FDhS-_Sc/UIsVn2KyASI/AAAAAAAAHFE/FwkdWM1sEsM/clip_image001_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="749" /&gt;&lt;/a&gt; &lt;br /&gt;
You'll then be asked to choose your project name, location, folder structure, and what to import. You can choose the defaults if you want. If you have an intricate permissions structure, you may want to import the permissions. If your logins, users, and permissions tend to vary by environment, you may want a different way to handle those. That will be covered in the "Permissions" section. &lt;br /&gt;
You'll have several options for folder structure. I'd choose the recommended structure unless you have a reason to choose something else. That will structure all of your objects under their appropriate schema, by object type. If you have a relatively simple database model, you may choose to structure your project by schema alone, object type alone, or just put everything in the root of the project. This only affects your project file structure, not your database structure. &lt;br /&gt;
Once you're satisfied with your settings, click the "Start" button to begin populating your project. &lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/-PBTa4as8Nvg/UIsVomonDaI/AAAAAAAAHFM/3JwxMHVdvnU/s1600-h/clip_image002%25255B4%25255D.png"&gt;&lt;img alt="clip_image002" border="0" height="556" src="http://lh6.ggpht.com/-QdmgsMX_YMk/UIsVpGcy1tI/AAAAAAAAHFU/JHqpp3awGAA/clip_image002_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image002" width="673" /&gt;&lt;/a&gt; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Importing From a Dacpac File&lt;/b&gt; &lt;br /&gt;
SSDT supports importing from a dacpac file. This can be useful if you're working on a project for a database to which you do not have direct access in order to import the schema directly. These files also can be used as external database references if you work in an environment where multiple databases interact. &lt;br /&gt;
In order to create a dacpac file, you have a couple of options. &lt;br /&gt;
You can generate a dacpac file from a SQL Server database using SSMS 2012. Right-click the database you wish to use. Select Tasks, then "Extract Data-tier Application…". &lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/-quWBrX1h-ZA/UIsVp_JoLTI/AAAAAAAAHFc/55KoWIO5rbk/s1600-h/clip_image003%25255B4%25255D.png"&gt;&lt;img alt="clip_image003" border="0" height="553" src="http://lh3.ggpht.com/-iAIG25CdbHs/UIsVqsGluAI/AAAAAAAAHFk/QVfGNl7RKtE/clip_image003_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image003" width="784" /&gt;&lt;/a&gt; &lt;br /&gt;
Set the file location and any other options you want to use. &lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/-OsnkxxZLmlw/UIsVrpJcEUI/AAAAAAAAHFs/AZZV_UI94Do/s1600-h/clip_image004%25255B4%25255D.png"&gt;&lt;img alt="clip_image004" border="0" height="640" src="http://lh4.ggpht.com/-lTnc76fd1Js/UIsVsPHoPWI/AAAAAAAAHF0/znO_H_Q8ZA4/clip_image004_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image004" width="688" /&gt;&lt;/a&gt; &lt;br /&gt;
Click next. Verify the settings. Click Next again. The system will now generate a dacpac file in the location you specified. &lt;br /&gt;
Note that choosing the "Export Data-tier Application" will create a bacpac file. This is used to backup all schema and data in a database so it can be published to an Azure database. You cannot use a bacpac file to import schema into your project. &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Generating a dacpac using SQLPackage.exe&lt;/b&gt; &lt;br /&gt;
You can always use the SQLPackage command line to extract the DB Schema into a dacpac file. For a complete list of parameters, see &lt;a href="http://msdn.microsoft.com/en-us/library/hh550080%28v=VS.103%29.aspx"&gt;http://msdn.microsoft.com/en-us/library/hh550080%28v=VS.103%29.aspx&lt;/a&gt;. &lt;br /&gt;
For a quick extraction from a trusted server, you can run something like the following: &lt;br /&gt;
&lt;blockquote&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:703c6ed2-f511-49b2-b5c4-5bc2e7d0ff24" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;div style="border: #000080 1px solid; color: black; font-family: 'Courier New', Courier, Monospace; font-size: 10pt;"&gt;
&lt;div style="background: #000080; color: white; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;"&gt;
Code Snippet&lt;/div&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto;"&gt;
&lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt;
&lt;li&gt;Sqlpackage.exe /a:extract /ssn:localhost /sdn:Adventureworks2008 /tf:Adventureworks2008.dacpac&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
This command uses an "Action" to Extract the file, with the SourceServerName of localhost, a SourceDatabaseName of Adventureworks2008, and a TargetFile of Adventureworks2008.dacpac    &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;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;img src="http://feeds.feedburner.com/~r/SchottSql/~4/d0Nz4PoVNTE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/d0Nz4PoVNTE/ssdt-importing-existing-database.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-8S9FDhS-_Sc/UIsVn2KyASI/AAAAAAAAHFE/FwkdWM1sEsM/s72-c/clip_image001_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/10/ssdt-importing-existing-database.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-6575473358587779370</guid><pubDate>Sat, 27 Oct 2012 13:00:00 +0000</pubDate><atom:updated>2012-10-27T08:00:08.467-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Creating a New SQL Project</title><description>Download the latest SSDT package if you do not have the product installed already:  &lt;br /&gt;
&lt;a href="http://msdn.microsoft.com/en-us/data/tools.aspx"&gt;http://msdn.microsoft.com/en-us/data/tools.aspx&lt;/a&gt; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
To create a new SQL Project, you can either start by creating a new Project or create a new project from an existing database. &lt;br /&gt;
When creating a brand new project, be sure to choose the "SQL Server Database Project". &lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/-bFXQdnjYUAU/UIsUbtW90yI/AAAAAAAAHD8/hx5cr4QOJjA/s1600-h/clip_image001%25255B4%25255D.png"&gt;&lt;img alt="clip_image001" border="0" height="333" src="http://lh3.ggpht.com/-DjGo8dqqIEU/UIsUcPXDWMI/AAAAAAAAHEE/NiECzZyamLg/clip_image001_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="626" /&gt;&lt;/a&gt; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
This is not the same as the Database -&amp;gt; SQL Server Project template. Using this will create a usable DB Project, but &lt;i&gt;not&lt;/i&gt; the newer SQL Project. &lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/-eJNxw_cClGw/UIsUc1e8kGI/AAAAAAAAHEM/CHQqR8gK2LQ/s1600-h/clip_image002%25255B6%25255D.png"&gt;&lt;img alt="clip_image002" border="0" height="426" src="http://lh3.ggpht.com/-BGYWKmpNMC8/UIsUdbqep7I/AAAAAAAAHEU/E0O-pZTJvZk/clip_image002_thumb%25255B3%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image002" width="617" /&gt;&lt;/a&gt; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
Once you've created a new, empty project, you'll need to populate the project in order to be able to use it. You have a couple of options. You can import from an existing database, import from a Dacpac file, or just start creating your objects if this is a completely new project. &lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&amp;nbsp; &lt;br /&gt;
&lt;b&gt;To Start a New Project from a Connected Database&lt;/b&gt; &lt;br /&gt;
Open your "SQL Server Object Explorer" window. Connect to the database server containing the database for which you want to create a project. Right-click that database and choose the "Create New Project…" option. &lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/-NeCQWAKsYHs/UIsUeN_Ou-I/AAAAAAAAHEc/CkvHDKfUb7M/s1600-h/clip_image003%25255B4%25255D.png"&gt;&lt;img alt="clip_image003" border="0" height="176" src="http://lh4.ggpht.com/-MNOIqW1dPik/UIsUesTip2I/AAAAAAAAHEk/3L1c9B2JrNg/clip_image003_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image003" width="409" /&gt;&lt;/a&gt; &lt;br /&gt;
You'll then be asked to choose your project name, location, folder structure, and what to import. You can choose the defaults if you want. If you have an intricate permissions structure, you may want to import the permissions. If your logins, users, and permissions tend to vary by environment, you may want a different way to handle those. That will be covered in the "Permissions" section. &lt;br /&gt;
You'll have several options for folder structure. I'd choose the recommended structure unless you have a reason to choose something else. That will structure all of your objects under their appropriate schema, by object type. If you have a relatively simple database model, you may choose to structure your project by schema alone, object type alone, or just put everything in the root of the project. This only affects your project file structure, not your database structure. &lt;br /&gt;
Once you're satisfied with your settings, click the "Start" button to begin populating your project. &lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/-cB3LvHNJeXQ/UIsUfE1aJFI/AAAAAAAAHEs/nNl5YjfNKHo/s1600-h/clip_image004%25255B5%25255D.png"&gt;&lt;img alt="clip_image004" border="0" height="431" src="http://lh4.ggpht.com/-ONbO0s-T8js/UIsUf7pJ73I/AAAAAAAAHE0/txVolVCnGYw/clip_image004_thumb%25255B2%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image004" width="522" /&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;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/v1sDJ_mTGjE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/v1sDJ_mTGjE/ssdt-creating-new-sql-project.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-DjGo8dqqIEU/UIsUcPXDWMI/AAAAAAAAHEE/NiECzZyamLg/s72-c/clip_image001_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/10/ssdt-creating-new-sql-project.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-2494280024940961755</guid><pubDate>Fri, 26 Oct 2012 22:50:00 +0000</pubDate><atom:updated>2012-10-26T18:39:40.533-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SSDT: Why Use SQL Projects?</title><description>&lt;b&gt;What Are SQL Projects and why use them?&lt;/b&gt; &lt;br /&gt;
SQL Server has always been lacking in a good solution to control versions of your database. We make changes directly to the database and if we're good, we remember to take backups. If we're really good, we save scripts so we can make those changes elsewhere. Too often, we resort to tools for schema differences or try to save up all of the scripts to replay them later. Both have some advantages. Schema differences guarantee that you can make two environments look the same. Scripts can be replayed in order to keep the systems in sync. However, a schema difference doesn't handle data changes well and can't handle making partial changes when not everything is ready to promote. Sets of scripts can also work well, but fail if you end up needing to push sub-sets of those scripts because certain functionality isn't going to be released yet. &lt;br /&gt;
Borrowing from Gert Drapers' excellent discussions on Database Development Challenges: &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Databases are inherently stateful &lt;ul&gt;
&lt;li&gt;ALTERs are generally run instead of DROP/CREATE &lt;/li&gt;
&lt;li&gt;Dependencies can greatly complicate the changes and scripts &lt;/li&gt;
&lt;li&gt;Data needs to be persisted&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Databases are often not integrated well with the application development life cycle &lt;/li&gt;
&lt;li&gt;DB Versions are frequently not persisted or managed well &lt;/li&gt;
&lt;li&gt;SQL Scripts may not handle different SQL Server versions well&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;Sequential Change Scripts&lt;/b&gt; &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Required to run in a set order &lt;ul&gt;
&lt;li&gt;Script 1, Script 2, Script 3, … &lt;/li&gt;
&lt;li&gt;Can't do Script 1, Script 4, Script 9&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Validating the end state after script runs vs. an expected end state can be complex &lt;/li&gt;
&lt;li&gt;Could easily miss a script in the sequence without knowing &lt;/li&gt;
&lt;li&gt;Handling a release where scripts need to be "skipped" can cause cascading dependency problems &lt;/li&gt;
&lt;li&gt;Can require extensive use of IF NOT EXISTS statements &lt;/li&gt;
&lt;li&gt;Manual process &lt;/li&gt;
&lt;li&gt;Point in time model &lt;/li&gt;
&lt;li&gt;Used by systems such as DBDiff&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;Declarative Model&lt;/b&gt; &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The model is the desired end state &lt;ul&gt;
&lt;li&gt;Compare the current state of the target against the desired end state &lt;/li&gt;
&lt;li&gt;Use the differences to generate an upgrade plan &lt;/li&gt;
&lt;li&gt;Use the upgrade plan to generate a change script, correctly ordered to bring the target up to the desired end state&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Generated / Programmatic process &lt;/li&gt;
&lt;li&gt;Always current &lt;/li&gt;
&lt;li&gt;Used by Red Gate, Microsoft, DB Ghost&lt;/li&gt;
&lt;/ul&gt;
Microsoft and Red Gate have both provided solutions to store versions of database schemas. While Red Gate offers a good product, it also requires some external tools to provide a complete solution for schema control. Until recently, Microsoft's solution wasn't accessible to everyone because it required a copy of Visual Studio to handle even the basics. This improved in Visual Studio 2010, but still required a separate purchase. With SQL Server 2012, Microsoft introduced SQL Server Data Tools and SQL projects. &lt;br /&gt;
With SQL projects, developers can store a version of their database objects in a source control system of their choice. Tables, stored procedures, views, and even permissions can be stored in such a way as to provide upgrades to databases and even build a new set of databases from scratch. This could even be used to build and release these databases continuously in an automated fashion to release new code.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/COcCmy4s6yA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/COcCmy4s6yA/why-use-sql-projects.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2012/10/why-use-sql-projects.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-5208106334651134187</guid><pubDate>Fri, 16 Dec 2011 01:59:00 +0000</pubDate><atom:updated>2011-12-15T20:01:01.297-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MySQL</category><category domain="http://www.blogger.com/atom/ns#">SSIS</category><title>Tales of a Lazy DBA–MySQL, SSIS, and “0” Dates</title><description>&lt;br /&gt;
We’ve recently been tasked with converting a lot of MySQL Data into our system from a multi-tenant MySQL Database. We don’t have a fixed schedule to actually execute the imports because they’ll be on a “per customer” basis.&amp;nbsp; Well, that sounded like a great task for SSIS.&amp;nbsp; I set up the ODBC driver, connected, set the initial “sql_mode” options for our connections to (‘mssql, allow_invalid_dates’) and started to work.&lt;br /&gt;
First problem we ran into with an ADO.NET connection to MySQL and writing a SELECT * from schema.table was when we hit a MySQL “Date” column containing a value of ‘0000-00-00’.&amp;nbsp; SSIS threw an error, not sure what to do.&amp;nbsp; Thanks to some others who have solved this problem, I realized that within the MySQL Select statement, we could do something like: &lt;br /&gt;
&lt;blockquote&gt;
CASE date_created WHEN '0000-00-00' THEN NULL else date_created END as date_created &lt;/blockquote&gt;
to pass those dates over as NULL. That solves the implicit conversion to datetime (SQL 2005) and avoids the invalid dates.&amp;nbsp; I ran something similar for a “Time” column to:  &lt;br /&gt;
&lt;blockquote&gt;
CAST(Time_Created as char(8) ) as Time_Created&lt;/blockquote&gt;
&amp;nbsp; &lt;br /&gt;
So that solved one particular table export with about 20 or so CAST and CASE statements.&amp;nbsp; Needless to say, I wasn’t looking forward to doing this for another 500 tables with a total of almost 6000 columns.  &lt;br /&gt;
I finally set up a really basic query to generate most of the SELECT statements we would need to pull our MySQL data across without too much pain. Admittedly, a small step and I’d still need to copy/paste when I set up each new ADO.NET source, but it worked reasonably well. I’m adding the code snippet for MySQL here in case anyone else has a similar problem. &lt;br /&gt;
&lt;div id="codeSnippetWrapper" style="background-color: #f4f4f4; border-bottom: silver 1px solid; border-left: silver 1px solid; border-right: silver 1px solid; border-top: silver 1px solid; cursor: text; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; height: 335px; line-height: 12pt; margin: 20px 0px 10px; max-height: 500px; overflow: auto; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left; width: 107.43%;"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;select&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;CONCAT(&lt;span style="color: blue;"&gt;CASE&lt;/span&gt; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; ordinal_position = 1 &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; &lt;span style="color: #006080;"&gt;'SELECT '&lt;/span&gt; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt; &lt;span style="color: #006080;"&gt;', '&lt;/span&gt; &lt;span style="color: blue;"&gt;END&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt; &lt;span style="color: blue;"&gt;CASE&lt;/span&gt; Data_Type &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: #006080;"&gt;'date'&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; CONCAT(&lt;span style="color: #006080;"&gt;'CASE '&lt;/span&gt;,column_name,&lt;span style="color: #006080;"&gt;' WHEN '&lt;/span&gt;&lt;span style="color: #006080;"&gt;'0000-00-00'&lt;/span&gt;&lt;span style="color: #006080;"&gt;' THEN NULL else '&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;    ,column_name,&lt;span style="color: #006080;"&gt;' END as '&lt;/span&gt;,column_name)&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: #006080;"&gt;'time'&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; CONCAT(&lt;span style="color: #006080;"&gt;'CAST('&lt;/span&gt;,column_name,&lt;span style="color: #006080;"&gt;' AS CHAR(8) ) as '&lt;/span&gt;,column_name)&lt;/pre&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt; column_name &lt;span style="color: blue;"&gt;END&lt;/span&gt;, &lt;span style="color: blue;"&gt;CASE&lt;/span&gt; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; Ordinal_Position &amp;lt;&amp;gt; MaxOrd &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; &lt;span style="color: #006080;"&gt;''&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt; CONCAT(&lt;span style="color: #006080;"&gt;'&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;    FROM MySchema.', c.table_name) &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;    ) &lt;span style="color: blue;"&gt;as&lt;/span&gt; Select_Column_Name&lt;/pre&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;from&lt;/span&gt; information_schema.columns &lt;span style="color: blue;"&gt;as&lt;/span&gt; c&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;JOIN&lt;/span&gt; (&lt;span style="color: blue;"&gt;select&lt;/span&gt; table_name, &lt;span style="color: blue;"&gt;MAX&lt;/span&gt;(ordinal_position) &lt;span style="color: blue;"&gt;as&lt;/span&gt; MaxOrd&lt;/pre&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;from&lt;/span&gt; information_schema.columns&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; Table_Schema = &lt;span style="color: #006080;"&gt;'MySchema'&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;GROUP&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; Table_Name) &lt;span style="color: blue;"&gt;as&lt;/span&gt; t1&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;ON&lt;/span&gt; c.Table_Name = t1.Table_Name&lt;/pre&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;where&lt;/span&gt; table_schema = &lt;span style="color: #006080;"&gt;'MySchema'&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;order&lt;/span&gt; &lt;span style="color: blue;"&gt;by&lt;/span&gt; c.table_name, ordinal_position &lt;span style="color: blue;"&gt;LIMIT&lt;/span&gt; 0, 50000;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I’d love to hear other ideas if anyone has encountered this before and come up with a more elegant solution for translating “0” Date or Time data from MySQL into SQL Server.&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/T0NU9mFAfOs" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/T0NU9mFAfOs/tales-of-lazy-dbamysql-ssis-and-0-dates.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>2</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2011/12/tales-of-lazy-dbamysql-ssis-and-0-dates.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-3963021819500641405</guid><pubDate>Thu, 15 Sep 2011 21:13:00 +0000</pubDate><atom:updated>2011-09-15T16:13:09.407-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VM</category><category domain="http://www.blogger.com/atom/ns#">Powerpivot</category><category domain="http://www.blogger.com/atom/ns#">Sharepoint</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">Virtual Machine</category><title>Installing SQL Server, Sharepoint, PowerPivot on a single server</title><description>I've been trying to set up a single virtual machine for a proof of concept using SQL Server Denali CTP3, Sharepoint 2010, and PowerPivot. I want to get Project "Crescent" running through this as well to prove out some report concepts. I've had a lot of trouble finding the right steps to get everything installed and working correctly on a single box, especially since my Sharepoint knowledge right now is practically non-existent when it comes to BI. Every time I tried to get the Sharepoint / PowerPivot integration working, I hit a roadblock or managed to corrupt my Sharepoint install.&lt;br /&gt;
&lt;br /&gt;
I had the opportunity to speak with Brian Knight ( &lt;a href="http://www.bidn.com/blogs/brianknight/"&gt;blog&lt;/a&gt; | &lt;a href="http://twitter.com/brianknight"&gt;twitter&lt;/a&gt; ) and he pointed me to &lt;a href="http://powerpivotpro.com/"&gt;PowerPivotPro.com&lt;/a&gt; which, in turn, led me to &lt;a href="http://powerpivotgeek.com/"&gt;PowerPivotGeek.com&lt;/a&gt;. They had a &lt;a href="http://powerpivotgeek.com/server-installation/single-server-install-rtm/"&gt;page of instructions for single-server installs&lt;/a&gt; with a pointer to an MS whitepaper and a private cached file of the whitepaper just in case. This gave me the information needed to get PowerPivot working on my VM.&lt;br /&gt;
&lt;br /&gt;
A couple of notes from my personal experience:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Install Sharepoint SP1 right after installing Sharepoint 2010. SP1 is required when you're using Denali&lt;/li&gt;
&lt;li&gt;Do NOT configure Sharepoint until the directions tell you to do so.&lt;/li&gt;
&lt;li&gt;Use a Named Instance in order to get PowerPivot working.&lt;/li&gt;
&lt;li&gt;If you plan to use Crescent, make sure that you set up SSAS with the "Tabular Data" option (or whatever the final name ends up being).&lt;/li&gt;
&lt;/ul&gt;
Once again, thanks to Brian for pointing me towards the right solution. Thanks to PowerPivotGeek for hosting these files. I imagine the instructions would work for Virtual Server, Virtual PC, VMWare, VirtualBox, or similar Virtual Machine apps. I hope this is helpful to anyone else trying to set up their own VM for testing out the Microsoft BI stack.&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/uoXkQc7FPYk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/uoXkQc7FPYk/installing-sql-server-sharepoint.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2011/09/installing-sql-server-sharepoint.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-7238075277541536976</guid><pubDate>Wed, 29 Jun 2011 18:45:00 +0000</pubDate><atom:updated>2011-06-29T13:57:11.294-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Service Broker</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">Performance</category><title>Service Broker–WAITFOR and Activated Queues</title><description>&lt;p&gt;We’ve implemented Service Broker for handling a small portion of the transactions we want to catch and apply into our Operational Data Store. Mostly we wanted to make sure we accounted for actual DELETE operations and handled those records correctly. We can use Change Data Capture at this time on our source systems and Service Broker seemed to fit the bill. We still handle the remaining inserts and updates through SSIS.&lt;/p&gt; &lt;p&gt;While running Service Broker, we noticed a pretty constant CPU hum on the receiving server. That seemed odd, but we had a lot of trouble tracking it down. Regular Profiler traces didn’t show any running TSQL, “normal” Service Broker traces weren’t showing much, either. We just saw SQL Server running at a pretty constant 20% even with nothing seemingly happening.&lt;/p&gt; &lt;p&gt;I want to give a public thank you to Mark Hill (&lt;a href="http://twitter.com/ftdba" target="_blank"&gt;twitter&lt;/a&gt;) for doing a little extra digging and catching the root cause of this. In our tinkering with Service Broker, Queues, Activation, Stored Procs, and such we missed some &lt;a href="http://msdn.microsoft.com/en-us/library/ms166135.aspx" target="_blank"&gt;very important information&lt;/a&gt; along the way.&lt;/p&gt; &lt;p&gt;We had written a stored procedure that would be used on the Receiving side of our Service Broker queue to run as the “Activated” proc. Inside the stored procedure, we included a WHILE loop to process anything that was in the queue. If nothing, exit.&amp;nbsp; That seemed pretty simple – if something comes into the queue, process it and stop when nothing is left.&amp;nbsp; End of story, right?&lt;/p&gt; &lt;p&gt;Sadly, this is where we missed a small, but important, fact about Service Broker. If you have an activated stored procedure that doesn’t use the WAITFOR command, Service Broker, we execute that stored proc as many times as possible looking for something to process. We looked at it, turned off the Activation on the queue and saw the CPU drop to nothing. We re-activated the queue and saw the CPU shoot up again. We tweaked the stored procedure after that and added a WAITFOR command with a timeout of 60000. After doing this, we saw the stored procedure run to process everything in the queue, then go idle, which was exactly the intended behavior in the first place.&lt;/p&gt; &lt;p&gt;I’m not going to pretend to be an expert on Service Broker. We had tried to code with the intention of being able to use this stored procedure as an Activated stored procedure or as one called from an external process to work through the queue. While that may be possible, it was unnecessary in our actual usage. Adding a WAITFOR command around our queue processing eliminated our extra, non-essential CPU usage and stopped trying to execute a stored procedure for no reason.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Pro SQL Server 2008 Service Broker ( &lt;a href="http://www.amazon.com/Server-Service-Broker-Books-Professionals/dp/1590599993" target="_blank"&gt;Amazon&lt;/a&gt; | &lt;a href="http://www.apress.com/9781590599990" target="_blank"&gt;Apress&lt;/a&gt; )&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms187331.aspx" target="_blank"&gt;WAITFOR&lt;/a&gt; (Also see &lt;a href="http://msdn.microsoft.com/en-us/library/ms166135.aspx" target="_blank"&gt;this performance article&lt;/a&gt; – it’s the little details that get you)&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/AqE1iXZMoVg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/AqE1iXZMoVg/service-brokerwaitfor-and-activated.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2011/06/service-brokerwaitfor-and-activated.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-1027485506554587657</guid><pubDate>Thu, 17 Feb 2011 22:15:00 +0000</pubDate><atom:updated>2011-02-17T16:15:36.801-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>Quickly script permissions in SQL 2005+</title><description>&lt;p&gt;I wanted an easy way to generate a script to recreate all DB object and schema permissions for a database. Searching online, I found several different examples, but none quite did everything I needed. I put this together from some examples and added it to my toolkit. This script will generate the appropriate T-SQL to grant permissions to DB Objects and Schemas.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; padding-left: 0px; width: 432px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:f928f839-ef42-42b3-b940-deb82dbc322b" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 432px; height: 565px;background-color:White;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #0000FF;"&gt;SELECT&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;state_desc &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; permission_name &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; on [&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; ss.name &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;].[&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; so.name &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;]&lt;br /&gt;to [&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdpr.name &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;]&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;COLLATE LATIN1_General_CI_AS &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;as&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;[&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;Permissions T-SQL&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;]&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;FROM&lt;/span&gt;&lt;span style="color: #000000;"&gt; SYS.DATABASE_PERMISSIONS &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;AS&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdp&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;JOIN&lt;/span&gt;&lt;span style="color: #000000;"&gt; sys.objects &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;AS&lt;/span&gt;&lt;span style="color: #000000;"&gt; so&lt;br /&gt;     &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;ON&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdp.major_id &lt;/span&gt;&lt;span style="color: #808080;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; so.&lt;/span&gt;&lt;span style="color: #FF00FF;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;JOIN&lt;/span&gt;&lt;span style="color: #000000;"&gt; SYS.SCHEMAS &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;AS&lt;/span&gt;&lt;span style="color: #000000;"&gt; ss&lt;br /&gt;     &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;ON&lt;/span&gt;&lt;span style="color: #000000;"&gt; so.SCHEMA_ID &lt;/span&gt;&lt;span style="color: #808080;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; ss.SCHEMA_ID&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;JOIN&lt;/span&gt;&lt;span style="color: #000000;"&gt; SYS.DATABASE_PRINCIPALS &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;AS&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdpr&lt;br /&gt;     &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;ON&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdp.grantee_principal_id &lt;/span&gt;&lt;span style="color: #808080;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdpr.principal_id&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;UNION&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;SELECT&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;state_desc &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; permission_name &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; on Schema::[&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; ss.name &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;]&lt;br /&gt;to [&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdpr.name &lt;/span&gt;&lt;span style="color: #808080;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;]&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;COLLATE LATIN1_General_CI_AS &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;as&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;[&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;Permissions T-SQL&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;]&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;FROM&lt;/span&gt;&lt;span style="color: #000000;"&gt; SYS.DATABASE_PERMISSIONS &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;AS&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdp&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;JOIN&lt;/span&gt;&lt;span style="color: #000000;"&gt; SYS.SCHEMAS &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;AS&lt;/span&gt;&lt;span style="color: #000000;"&gt; ss&lt;br /&gt;     &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;ON&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdp.major_id &lt;/span&gt;&lt;span style="color: #808080;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; ss.SCHEMA_ID&lt;br /&gt;     &lt;/span&gt;&lt;span style="color: #808080;"&gt;AND&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdp.class_desc &lt;/span&gt;&lt;span style="color: #808080;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;Schema&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;JOIN&lt;/span&gt;&lt;span style="color: #000000;"&gt; SYS.DATABASE_PRINCIPALS &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;AS&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdpr&lt;br /&gt;     &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;ON&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdp.grantee_principal_id &lt;/span&gt;&lt;span style="color: #808080;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdpr.principal_id&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;order&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;by&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;[&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;Permissions T-SQL&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;]&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;GO&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;I know that a lot of you may have something that does this already, but figured it can’t hurt to have another snippet available to generate permission statements. If you make any enhancements, let me know. I’d love to keep this up to date so it’s helpful to others.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/MpSV14cTl9w" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/MpSV14cTl9w/quickly-script-permissions-in-sql-2005.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>5</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2011/02/quickly-script-permissions-in-sql-2005.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-7341104230998013980</guid><pubDate>Mon, 07 Feb 2011 22:27:00 +0000</pubDate><atom:updated>2011-02-07T16:27:52.444-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SSIS</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SQL 2008 R2 – SSIS Data Export Oddities</title><description>&lt;p&gt;I don’t know if anyone else has had these sorts of issues, but we work quite a bit with conversions of various source data into our SQL Server database. I recently was handed a backup from SQL 2008 R2. I figured that wasn’t a huge problem. Restore onto my local test box, use SSIS to push over to a SQL 2005 instance so it can work its way to Production. No big deal, right?&lt;/p&gt; &lt;p&gt;The first time I tried this using the SQL Native Client 10.0 on both sides, I ran into an errors with the mappings. I can’t quite figure that one out because from what I can see, there’s nothing at all in the source database using a feature that would not be available in SQL 2005.&lt;/p&gt; &lt;p&gt;I tried exporting to an MS Access MDB file. No luck from SQL 2008 R2 with the default settings because of an invalid size error on a varchar to longtext conversion.&lt;/p&gt; &lt;p&gt;I was able to successfully export using SNAC from SQL 2008 R2 to a SQL 2008 instance. So from &lt;em&gt;there&lt;/em&gt; I thought I could upload directly to the SQL 2005 instance. No such luck using SNAC – again. I &lt;em&gt;was&lt;/em&gt; able to export from there to an Access MDB file and pull that into SQL 2005.&amp;nbsp; I don’t quite get why that worked, but figure I’ve got some odd mapping in the XML files defining the defaults that I’m missing.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I was recently asked to repeat this task and figured there had to be a better way. This time I restored the DB to my R2 instance – no issues. I then used the SNAC client to access my R2 instance, but set up an OLEDB connection to my SQL Server 2005 target. For some reason, the mappings are just different enough that this worked with no issues. I was able to transfer directly. I now wish I’d tried that the first time, but I’d already blown a couple of hours on it.&lt;/p&gt; &lt;p&gt;If anyone else has encountered that and knows why SNAC from 2008 R2 doesn’t seem to work directly to SNAC on 2005, I’d love to know the reasons as well. If not and you encounter something similar, maybe trying the OLEDB connections will work for you.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/k8c_UtuI1GA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/k8c_UtuI1GA/sql-2008-r2-ssis-data-export-oddities.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2011/02/sql-2008-r2-ssis-data-export-oddities.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-6965670211952326751</guid><pubDate>Mon, 17 Jan 2011 18:24:00 +0000</pubDate><atom:updated>2011-01-17T12:24:35.923-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SQL</category><title>SQL 2008 Merge and PK/FK Constraints</title><description>We ran into this issue a while back.&amp;nbsp; SQL 2008 has a “feature” that will not allow inserts into a table on either side of a Foreign Key relationship.&amp;nbsp; If you attempt to insert into a table involved in the FK relationship, you get an error something like:&lt;br /&gt;
&lt;blockquote&gt;&lt;span style="color: red;"&gt;The target table 'TableName' of the INSERT statement cannot be on either side of a (primary key, foreign key) relationship when the FROM clause contains a nested INSERT, UPDATE, DELETE, or MERGE statement. Found reference constraint 'ConstraintName'.&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: black;"&gt;This is documented in &lt;a href="https://connect.microsoft.com/SQLServer/feedback/details/435031" target="_blank"&gt;Connect 435031&lt;/a&gt;. There is one workaround documented in the ticket – drop the FK constraint, run the MERGE query, then re-create the constraint. Happily, this bug is still open as the requirement to drop a constraint just to run a MERGE statement kind of defeats the purpose of putting a constraint on the table in the first place. While dropping the constraints will work, there is another possible workaround. &lt;span style="color: black;"&gt;I was able to run this without any issues while leaving my FK Constraint in place.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style="color: black;"&gt;Create a temp table that matches the definition of the table into which you want to perform your insert.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: black;"&gt;Instead of inserting into your base table like you normally would in a merge, write your code to INSERT #Tablename at the beginning of the MERGE process. You’ll still use your main table and staging table inside the MERGE INTO … USING query.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: black;"&gt;After the Merge, insert into the main table using the values in your Temp table.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;span style="color: black;"&gt;Here’s a shell of an example. Line 11 below contains the main difference to the MERGE query from a “normal” MERGE.&lt;/span&gt;&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt;   1:&lt;/span&gt; &lt;span style="color: green;"&gt;--1: Create Temp table&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt;   2:&lt;/span&gt; &lt;span style="color: blue;"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; #MyFactTable(&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt;   3:&lt;/span&gt;     ID &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: blue;"&gt;NULL&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt;   4:&lt;/span&gt;     , CustomerName &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;(100) &lt;span style="color: blue;"&gt;NULL&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt;   5:&lt;/span&gt;     , SourceID &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: blue;"&gt;NULL&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt;   6:&lt;/span&gt;     , OutputAction &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;(100) &lt;span style="color: blue;"&gt;NULL&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt;   7:&lt;/span&gt; );&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt;   8:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt;   9:&lt;/span&gt; &lt;span style="color: green;"&gt;--2: INSERT into the temp table instead of your normal target table&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt;  10:&lt;/span&gt; &lt;span style="color: green;"&gt;--   Merge query will be the same otherwise&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt;  11:&lt;/span&gt; &lt;b&gt;INSERT &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; #MyFactTable (ID, CustomerName, SourceID, OutputAction)&lt;/b&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt;  12:&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; so.ID, so.CustomerName, so.SourceID, so.output_action&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt;  13:&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; (&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt;  14:&lt;/span&gt;     MERGE &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; dbo.MyFactTable &lt;span style="color: blue;"&gt;AS&lt;/span&gt; t&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum15" style="color: #606060;"&gt;  15:&lt;/span&gt;     &lt;span style="color: blue;"&gt;USING&lt;/span&gt; Staging.MyFactTable &lt;span style="color: blue;"&gt;AS&lt;/span&gt; s&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum16" style="color: #606060;"&gt;  16:&lt;/span&gt;     &lt;span style="color: blue;"&gt;ON&lt;/span&gt; ( s.ID = t.ID&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum17" style="color: #606060;"&gt;  17:&lt;/span&gt;         &lt;span style="color: blue;"&gt;AND&lt;/span&gt; s.NewLoad = 0 )&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum18" style="color: #606060;"&gt;  18:&lt;/span&gt;         &lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum19" style="color: #606060;"&gt;  19:&lt;/span&gt;     &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; MATCHED &lt;span style="color: blue;"&gt;AND&lt;/span&gt; ( s.SourceID &amp;lt;&amp;gt; t.SourceID )&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum20" style="color: #606060;"&gt;  20:&lt;/span&gt;             &lt;span style="color: blue;"&gt;AND&lt;/span&gt; s.NewLoad = 0            &lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum21" style="color: #606060;"&gt;  21:&lt;/span&gt;     &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; &lt;span style="color: blue;"&gt;UPDATE&lt;/span&gt; &lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum22" style="color: #606060;"&gt;  22:&lt;/span&gt;         &lt;span style="color: blue;"&gt;SET&lt;/span&gt; RecordState = 0&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum23" style="color: #606060;"&gt;  23:&lt;/span&gt;         , UpdatedDate = getdate()&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum24" style="color: #606060;"&gt;  24:&lt;/span&gt;         &lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum25" style="color: #606060;"&gt;  25:&lt;/span&gt;     &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: blue;"&gt;NOT&lt;/span&gt; MATCHED &lt;span style="color: blue;"&gt;BY&lt;/span&gt; TARGET &lt;span style="color: blue;"&gt;AND&lt;/span&gt; s.NewLoad = 0 &lt;span style="color: blue;"&gt;THEN&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum26" style="color: #606060;"&gt;  26:&lt;/span&gt;         INSERT (ID, CustomerName, SourceID)&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum27" style="color: #606060;"&gt;  27:&lt;/span&gt;         &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt; (s.ID, s.CustomerName, s.SourceID)&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum28" style="color: #606060;"&gt;  28:&lt;/span&gt;         &lt;span style="color: blue;"&gt;OUTPUT&lt;/span&gt; $&lt;span style="color: blue;"&gt;action&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; OutputAction&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum29" style="color: #606060;"&gt;  29:&lt;/span&gt;             , ID&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum30" style="color: #606060;"&gt;  30:&lt;/span&gt;             , CustomerName&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum31" style="color: #606060;"&gt;  31:&lt;/span&gt;             , SourceID&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum32" style="color: #606060;"&gt;  32:&lt;/span&gt;         ) &lt;span style="color: blue;"&gt;AS&lt;/span&gt; so (OutputAction, ID, CustomerName, SourceID)&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum33" style="color: #606060;"&gt;  33:&lt;/span&gt;         &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; OutputAction = &lt;span style="color: #006080;"&gt;'UPDATE'&lt;/span&gt;  ;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum34" style="color: #606060;"&gt;  34:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum35" style="color: #606060;"&gt;  35:&lt;/span&gt;&lt;span style="color: green;"&gt; --3: Perform the final insert into your target table&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum36" style="color: #606060;"&gt;  36:&lt;/span&gt; INSERT &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; MyFactTable (ID, CustomerName, SourceID)&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum37" style="color: #606060;"&gt;  37:&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: blue;"&gt;DISTINCT&lt;/span&gt; ID, CustomerName, SourceID&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum38" style="color: #606060;"&gt;  38:&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; #MyFactTable ;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum39" style="color: #606060;"&gt;  39:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum40" style="color: #606060;"&gt;  40:&lt;/span&gt; &lt;span style="color: green;"&gt;--4: Clean up your temp objects.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum41" style="color: #606060;"&gt;  41:&lt;/span&gt; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; #MyFactTable ;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
I’d love to hear if anyone else has a workaround for this that doesn’t involve dropping and recreating the FK constraint. If this is an issue for you, please vote for the &lt;a href="https://connect.microsoft.com/SQLServer/feedback/details/435031" target="_blank"&gt;Connect Ticket&lt;/a&gt;.&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/ZqnmMJOzv4U" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/ZqnmMJOzv4U/sql-2008-merge-and-pkfk-constraints.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>2</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2011/01/sql-2008-merge-and-pkfk-constraints.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-8758965769141209605</guid><pubDate>Tue, 14 Dec 2010 04:00:00 +0000</pubDate><atom:updated>2010-12-13T22:15:34.956-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Book Review</category><title>Book Review: Windows Phone 7 Plain &amp; Simple</title><description>&lt;p&gt;&lt;a href="http://oreilly.com/catalog/9780735643420/" target="_blank"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="cat[1]" border="0" alt="cat[1]" align="left" src="http://lh4.ggpht.com/_SVlKer2O_7A/TQbvQtgnM5I/AAAAAAAAGUg/2QmBVkkZ63k/cat%5B1%5D%5B12%5D.gif?imgmax=800" width="142" height="125"&gt;&lt;/a&gt; Overall, &lt;a href="http://oreilly.com/catalog/9780735643420/" target="_blank"&gt;Windows Phone 7 Plain &amp;amp; Simple&lt;/a&gt; is a good book for people new to Windows Phone 7 and especially for people new to Smart Phones. Michael does a great job illustrating how to use the phone and get up to speed quickly. He walks quickly through the general operation, setting up the phone, and entering text in the first couple chapters. The next several chapters discuss using the most popular features of WP7: calling, e-mail, text messages, calendar, browsing the web, and using the maps/navigation. Next we learn more about music, video, taking pictures and videos, and using the Marketplace. We end with a quick session on using WP7's Office Hub for documents, spreadsheets, and OneNote. This is followed by a discussion on using the Zune software to synchronize files between your phone and your PC. (Michael doesn't mention the Mac software to do this. It's capable, but more limited.)  &lt;p&gt;Having followed the progress of WP7, I found that I knew a lot of the information in this book. There were still a couple interesting bits of information that were news to me, but not many. Michael didn’t write this for people like me who have followed WP7 for some time. He wrote for people who aren’t really familiar with smartphones and especially with the changes that WP7 brings. For those people, this will be a useful read and a quick reference while they get used to their device. I plan to show this to my family members who have WP7 devices and aren't quite sure what to do with them. &lt;p&gt;&lt;strong&gt;The positives:&lt;/strong&gt; &lt;ul&gt; &lt;li&gt;The information is very well presented, easy to follow, and broken out into logical sections.&lt;/li&gt; &lt;li&gt;Michael's casual writing is well-suited for this book.&lt;/li&gt; &lt;li&gt;Readers will not feel intimidated by their new phone and are encouraged to try things out.&lt;/li&gt; &lt;li&gt;Michael presents some information that you may not easily find by reading articles online. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;The negatives:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;I don't see this as a book that will be a long-lasting reference book. Once the reader has used the phone for a month or so, the lessons from this book should be second-nature.&lt;/li&gt; &lt;li&gt;WP7 already has two planned updates at the time of this review. A minor update in January 2011 that will reportedly enable Copy/Paste functionality and a larger one in February 2011. The errata for this book will need to be updated to take these changes into account as some information may be outdated. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Conclusion:&lt;br&gt;&lt;/strong&gt;If you can find Windows Phone 7 Plain &amp;amp; Simple for a reasonable price and are new to the platform, pick it up. It's a short, but informative, read. If you've followed WP7 for a while, this is not likely the book for you as you'll know most of the information here already. You may still want to pick up a copy to share with family or friends who are new to the phone. It could save you "support" calls.&lt;/p&gt; &lt;p&gt;Please visit the &lt;a href="http://oreilly.com/catalog/9780735643420/" target="_blank"&gt;Windows Phone 7 Plain &amp;amp; Simple page&lt;/a&gt; at O’Reilly for more information about this book. &lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; I received a free copy of this book in electronic format in return for providing an honest review. I was not compensated in any other way.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/A-nnkFs-Aa8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/A-nnkFs-Aa8/book-review-windows-phone-7-plain.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_SVlKer2O_7A/TQbvQtgnM5I/AAAAAAAAGUg/2QmBVkkZ63k/s72-c/cat%5B1%5D%5B12%5D.gif?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2010/12/book-review-windows-phone-7-plain.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-3606238101023404755</guid><pubDate>Tue, 30 Nov 2010 06:00:00 +0000</pubDate><atom:updated>2010-11-30T00:18:52.422-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Book Review</category><category domain="http://www.blogger.com/atom/ns#">Cooking</category><title>Book Review: Cooking For Geeks</title><description>&lt;p&gt;&lt;em&gt;(I know this isn’t SQL-related, but I think this may be a great read for people with similar interests.)&lt;/em&gt;&lt;/p&gt; &lt;p&gt;This is &lt;em&gt;not&lt;/em&gt; a cookbook. If you’re looking for a new collection of recipes, this is not the book for you. If you like shows like &lt;em&gt;Good Eats&lt;/em&gt; or enjoy seeing how food is prepared and served, you’ll almost certainly love &lt;em&gt;Cooking for Geeks&lt;/em&gt;. If you like experimenting in the kitchen and knowing why food turns out the way it does, pick up this book!&lt;/p&gt; &lt;p&gt;As a geek, I loved Jeff’s analogy: &lt;em&gt;Recipes are code&lt;/em&gt;. Follow a recipe as written and you generally get good results. Forget the where clause and you could have unrecoverable errors. Introduce your own changes and you could get something great or you could get something horrible that requires a lot of cleanup. Recipes may have bugs or need corrections. Perhaps there’s more than one way to the same result. Oh, and don’t forget to comment your recipe. Otherwise you might not be able to recreate something fantastic.&lt;/p&gt; &lt;p&gt;Each chapter of &lt;em&gt;Cooking for Geeks&lt;/em&gt; deals with different concepts, each with their own scientific background. Common utensils, ingredients, time/temperature, baking, additives (chemicals), and even some geeky fun with hardware or unusual cooking techniques – all are included in a way that not only gives some neat recipes, but the science behind the recipes.&lt;/p&gt; &lt;p&gt;To me, the most interesting parts were on baking and the chemical reactions that take place as heat is applied. It was great reading exactly &lt;em&gt;why&lt;/em&gt; food turns out with all of its various nuances. That science got me thinking about ways to tweak the outcome of various recipes I follow and was just fun to read.&lt;/p&gt; &lt;p&gt;You can get your own copy of &lt;em&gt;Cooking for Geeks&lt;/em&gt; &lt;a href="http://oreilly.com/catalog/9780596805883/" target="_blank"&gt;direct from O’Reilly&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Disclaimer: I received an electronic review copy of this book, though I’d likely have wanted to read and review this anyway.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SchottSql/~4/_MNFbGGfcxg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SchottSql/~3/_MNFbGGfcxg/book-review-cooking-for-geeks.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total><feedburner:origLink>http://schottsql.blogspot.com/2010/11/book-review-cooking-for-geeks.html</feedburner:origLink></item></channel></rss>
