<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-4845744956082769684</atom:id><lastBuildDate>Fri, 06 Nov 2026 08:26:40 +0000</lastBuildDate><category>SQL Server</category><category>SSDT</category><category>SQL Project</category><category>Version Control</category><category>PowerShell</category><category>SSIS</category><category>Scripting</category><category>SQL</category><category>VSTS DB Pro</category><category>Book Review</category><category>MySQL</category><category>Performance</category><category>Powerpivot</category><category>BIML</category><category>Cooking</category><category>Excel</category><category>SSAS</category><category>Service Broker</category><category>Sharepoint</category><category>VM</category><category>Virtual Machine</category><category>XML</category><title>Schott SQL</title><description>Note - this blog has moved to https://schottsql.com&#xa;Please follow my posts over there for the most recent updates.</description><link>http://schottsql.blogspot.com/</link><managingEditor>noreply@blogger.com (Peter Schott)</managingEditor><generator>Blogger</generator><openSearch:totalResults>55</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-7077217121658038834</guid><pubDate>Sat, 09 Sep 2023 00:11:00 +0000</pubDate><atom:updated>2023-09-08T19:11:24.491-05:00</atom:updated><title>New Site Home</title><description>&lt;p&gt;&amp;nbsp;Please note that this site has moved over to https://schottsql.com. Please follow me over there for the most recent posts and updates.&lt;br /&gt;&lt;/p&gt;</description><link>http://schottsql.blogspot.com/2023/09/new-site-home.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-9099160669956569464</guid><pubDate>Thu, 21 Apr 2016 20:43:00 +0000</pubDate><atom:updated>2016-04-21T15:43:38.437-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>Getting All Permissions for Server</title><description>&lt;p&gt;We recently had to work out a way to fetch and display all effective permissions granted to our Production SQL Server. I had been required to get all permissions at the DB level before, but even then that tended to be more granular and only showed to what roles you belonged and what explicit permissions you&#39;d been granted. We wanted to run something through a loop of all users and get that information into a report. It turns out this was easier than I&#39;d expected, especially after my first attempts to dig through the system tables.&lt;/p&gt; &lt;p&gt;We used a script something like the following:&lt;/p&gt; &lt;p&gt;EXECUTE as login = &#39;DomainName\Login&#39;;&lt;br&gt;select &#39;DomainName\Login&#39; AS Login, * from fn_my_permissions (NULL, &#39;SERVER&#39;);&lt;br&gt;REVERT;&lt;/p&gt; &lt;p&gt;With a little work this can be used within PowerShell or SQL to loop through all logins and capture the information in a table or report.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The function could also be used to loop through all databases by using the database and then substituting Database for Server above:&lt;/p&gt; &lt;p&gt;USE AdventureWorks2012;&lt;br&gt;EXECUTE as login = &#39;DomainName\Login&#39;;&lt;br&gt;SELECT &#39;DomainName\Login&#39;, * FROM fn_my_permissions (NULL, &#39;DATABASE&#39;);&lt;br&gt;REVERT;&lt;/p&gt; &lt;p&gt;For an interesting take on revamping sp_msforeachdb, check out &lt;a href=&quot;http://www.sqlservercentral.com/articles/sp_msforeachdb/117654/&quot; target=&quot;_blank&quot;&gt;this script&lt;/a&gt; from Edward Pollack (&lt;a href=&quot;https://twitter.com/EdwardPollack&quot; target=&quot;_blank&quot;&gt;t&lt;/a&gt;). It might help you if you need to loop through all of your databases to run something like this for your auditors.&lt;/p&gt;</description><link>http://schottsql.blogspot.com/2016/04/getting-all-permissions-for-server.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-4123710839275625355</guid><pubDate>Mon, 29 Feb 2016 15:35:00 +0000</pubDate><atom:updated>2016-02-29T09:36:05.767-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>SQL Server Audits and Action_IDs</title><description>&lt;p&gt;We were recently re-doing our SQL Server Audits and I was reminded again how painful setting the filters can be. MS expects an integer for &quot;action_id&quot;, but to actually use, them you need to know what those actually mean.&lt;/p&gt; &lt;p&gt;I came across &lt;a href=&quot;https://cprovolt.wordpress.com/2013/08/02/sql-server-audit-action_id-list/&quot; target=&quot;_blank&quot;&gt;this blog post&lt;/a&gt; by Chris Provolt listing the text versions of the action_id&#39;s. That was helpful, especially the quick query to see what&#39;s available:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;code&gt;Select DISTINCT action_id,name,class_desc,parent_class_desc from sys.dm_audit_actions&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;However, as you can tell by running this, the action_id&#39;s returned are all text values. That doesn&#39;t help when trying to set up your SQL Audits.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://blogs.msdn.microsoft.com/sqlsecurity/2012/10/03/filter-sql-server-audit-on-action_id-class_type-predicate/&quot; target=&quot;_blank&quot;&gt;MSDN provides code for a function&lt;/a&gt; to translate the text audit_id into the expected numeric value.&lt;/p&gt;&lt;font size=&quot;2&quot; face=&quot;Courier New&quot;&gt;&lt;font color=&quot;blue&quot;&gt;CREATE&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;FUNCTION&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;dbo&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;.&lt;/font&gt;&lt;font color=&quot;#ff0080&quot;&gt;&lt;b&gt;Getint_action_id&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#8000ff&quot;&gt;@action_id&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;VARCHAR&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;4&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt; &lt;br&gt;&lt;font color=&quot;maroon&quot;&gt;returns&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;INT&lt;/i&gt;&lt;/font&gt; &lt;br&gt;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;BEGIN&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;DECLARE&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;INT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt; &lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;SET&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;INT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;VARBINARY&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Upper&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt; &lt;br&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Substring&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#8000ff&quot;&gt;@action_id&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt; &lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;IF&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Len&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#8000ff&quot;&gt;@action_id&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;&amp;gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;2&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;SET&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;INT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;VARBINARY&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Upper&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt; &lt;br&gt;&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;&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; &lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Substring&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#8000ff&quot;&gt;@action_id&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;2&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt; &lt;br&gt;&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;&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; &lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt; &lt;br&gt;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;silver&quot;&gt;*&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Power&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt; &lt;br&gt;&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;black&quot;&gt;2&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;8&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;+&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;ELSE&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;SET&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;INT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;VARBINARY&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39; &#39;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;*&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Power&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;2&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;8&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;+&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt; &lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;IF&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Len&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#8000ff&quot;&gt;@action_id&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;&amp;gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;3&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;SET&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;INT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;VARBINARY&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Upper&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt; &lt;br&gt;&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;&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; &lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Substring&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#8000ff&quot;&gt;@action_id&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;3&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt; &lt;br&gt;&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;&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; &lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt; &lt;br&gt;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;silver&quot;&gt;*&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Power&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt; &lt;br&gt;&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;black&quot;&gt;2&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;16&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;+&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;ELSE&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;SET&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;INT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;VARBINARY&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39; &#39;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;*&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Power&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;2&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;16&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;+&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt; &lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;IF&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Len&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#8000ff&quot;&gt;@action_id&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;&amp;gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;4&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;SET&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;INT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;VARBINARY&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Upper&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt; &lt;br&gt;&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;&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; &lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Substring&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#8000ff&quot;&gt;@action_id&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;4&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt; &lt;br&gt;&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;&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; &lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt; &lt;br&gt;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;silver&quot;&gt;*&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Power&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt; &lt;br&gt;&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;black&quot;&gt;2&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;24&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;+&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;ELSE&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;SET&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;INT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;CONVERT&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;&lt;i&gt;VARBINARY&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39; &#39;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;*&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;fuchsia&quot;&gt;&lt;i&gt;Power&lt;/i&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;black&quot;&gt;2&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;24&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;+&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt; &lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;RETURN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#8000ff&quot;&gt;@x&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt; &lt;br&gt;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;END&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt;&amp;nbsp; &lt;/font&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Once you create that function, you can use it to generate a list of the Integer action_ids, the text action_ids, and the name/description of those action_ids. (You can also expand it out to see which actions are applicable to various objects at the server and database level if you so desire.)&lt;/p&gt;&lt;font size=&quot;2&quot; face=&quot;Courier New&quot;&gt;&lt;font color=&quot;blue&quot;&gt;SELECT&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;DISTINCT&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;dbo&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;.&lt;/font&gt;&lt;font color=&quot;#ff0080&quot;&gt;&lt;b&gt;Getint_action_id&lt;/b&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;action_id&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;Action_ID_Int&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;br&gt;&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; &lt;font color=&quot;maroon&quot;&gt;action_id&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;blue&quot;&gt;NAME&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;AS&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;Action_Description&lt;/font&gt; &lt;br&gt;&lt;font color=&quot;green&quot;&gt;&lt;i&gt;--,class_desc,parent_class_desc&lt;/i&gt;&lt;/font&gt; &lt;br&gt;&lt;font color=&quot;blue&quot;&gt;FROM&lt;/font&gt;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;maroon&quot;&gt;sys&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;.&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;dm_audit_actions&lt;/font&gt; &lt;br&gt;&lt;font color=&quot;blue&quot;&gt;ORDER&lt;/font&gt;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;BY&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;action_id&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;This will result in the following values (as of SQL 2012):  &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/p&gt; &lt;style type=&quot;text/css&quot;&gt;
	table.tableizer-table {
		font-size: 12px;
		border: 1px solid #ccc; 
		font-family: arial, helvetica, sans-serif;
	} 
	.tableizer-table td {
		padding: 4px;
		margin: 3px;
		border: 1px solid #ccc;
	}
	.tableizer-table th {
		background-color: #104e8b; 
		color: #fff;
		font-weight: bold;
	}
&lt;/style&gt;  &lt;table class=&quot;tableizer-table&quot;&gt; &lt;thead&gt; &lt;tr class=&quot;tableizer-firstrow&quot;&gt; &lt;th&gt;Action_ID_Int&lt;/th&gt; &lt;th&gt;action_id&lt;/th&gt; &lt;th&gt;NAME&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;1329873729&lt;/td&gt; &lt;td&gt;ACDO&lt;/td&gt; &lt;td&gt;DATABASE_OBJECT_ACCESS_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;542065473&lt;/td&gt; &lt;td&gt;ACO &lt;/td&gt; &lt;td&gt;SCHEMA_OBJECT_ACCESS_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1329742913&lt;/td&gt; &lt;td&gt;ADBO&lt;/td&gt; &lt;td&gt;BULK ADMIN&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1346651201&lt;/td&gt; &lt;td&gt;ADDP&lt;/td&gt; &lt;td&gt;DATABASE_ROLE_MEMBER_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1347634241&lt;/td&gt; &lt;td&gt;ADSP&lt;/td&gt; &lt;td&gt;SERVER_ROLE_MEMBER_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538987585&lt;/td&gt; &lt;td&gt;AL &lt;/td&gt; &lt;td&gt;ALTER&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1313033281&lt;/td&gt; &lt;td&gt;ALCN&lt;/td&gt; &lt;td&gt;ALTER CONNECTION&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1397902401&lt;/td&gt; &lt;td&gt;ALRS&lt;/td&gt; &lt;td&gt;ALTER RESOURCES&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1397967937&lt;/td&gt; &lt;td&gt;ALSS&lt;/td&gt; &lt;td&gt;ALTER SERVER STATE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1414745153&lt;/td&gt; &lt;td&gt;ALST&lt;/td&gt; &lt;td&gt;ALTER SETTINGS&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1381256257&lt;/td&gt; &lt;td&gt;ALTR&lt;/td&gt; &lt;td&gt;ALTER TRACE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1280462913&lt;/td&gt; &lt;td&gt;APRL&lt;/td&gt; &lt;td&gt;ADD MEMBER&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538989377&lt;/td&gt; &lt;td&gt;AS &lt;/td&gt; &lt;td&gt;ACCESS&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1129534785&lt;/td&gt; &lt;td&gt;AUSC&lt;/td&gt; &lt;td&gt;AUDIT SESSION CHANGED&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1179866433&lt;/td&gt; &lt;td&gt;AUSF&lt;/td&gt; &lt;td&gt;AUDIT SHUTDOWN ON FAILURE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1213486401&lt;/td&gt; &lt;td&gt;AUTH&lt;/td&gt; &lt;td&gt;AUTHENTICATE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538984770&lt;/td&gt; &lt;td&gt;BA &lt;/td&gt; &lt;td&gt;BACKUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;541868354&lt;/td&gt; &lt;td&gt;BAL &lt;/td&gt; &lt;td&gt;BACKUP LOG&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1111773762&lt;/td&gt; &lt;td&gt;BRDB&lt;/td&gt; &lt;td&gt;BACKUP_RESTORE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1179595331&lt;/td&gt; &lt;td&gt;C2OF&lt;/td&gt; &lt;td&gt;TRACE AUDIT C2OFF&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1313813059&lt;/td&gt; &lt;td&gt;C2ON&lt;/td&gt; &lt;td&gt;TRACE AUDIT C2ON&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1196180291&lt;/td&gt; &lt;td&gt;CCLG&lt;/td&gt; &lt;td&gt;CHANGE LOGIN CREDENTIAL&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1196182851&lt;/td&gt; &lt;td&gt;CMLG&lt;/td&gt; &lt;td&gt;CREDENTIAL MAP TO LOGIN&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1430343235&lt;/td&gt; &lt;td&gt;CNAU&lt;/td&gt; &lt;td&gt;AUDIT_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538988355&lt;/td&gt; &lt;td&gt;CO &lt;/td&gt; &lt;td&gt;CONNECT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538988611&lt;/td&gt; &lt;td&gt;CP &lt;/td&gt; &lt;td&gt;CHECKPOINT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538989123&lt;/td&gt; &lt;td&gt;CR &lt;/td&gt; &lt;td&gt;CREATE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538976324&lt;/td&gt; &lt;td&gt;D &lt;/td&gt; &lt;td&gt;DENY&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1179074884&lt;/td&gt; &lt;td&gt;DAGF&lt;/td&gt; &lt;td&gt;FAILED_DATABASE_AUTHENTICATION_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1279738180&lt;/td&gt; &lt;td&gt;DAGL&lt;/td&gt; &lt;td&gt;DATABASE_LOGOUT_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1397178692&lt;/td&gt; &lt;td&gt;DAGS&lt;/td&gt; &lt;td&gt;SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1178681924&lt;/td&gt; &lt;td&gt;DBAF&lt;/td&gt; &lt;td&gt;DATABASE AUTHENTICATION FAILED&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1396785732&lt;/td&gt; &lt;td&gt;DBAS&lt;/td&gt; &lt;td&gt;DATABASE AUTHENTICATION SUCCEEDED&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1128481348&lt;/td&gt; &lt;td&gt;DBCC&lt;/td&gt; &lt;td&gt;DBCC&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1195590212&lt;/td&gt; &lt;td&gt;DBCG&lt;/td&gt; &lt;td&gt;DBCC_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;541868612&lt;/td&gt; &lt;td&gt;DBL &lt;/td&gt; &lt;td&gt;DATABASE LOGOUT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538987588&lt;/td&gt; &lt;td&gt;DL &lt;/td&gt; &lt;td&gt;DELETE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1280462916&lt;/td&gt; &lt;td&gt;DPRL&lt;/td&gt; &lt;td&gt;DROP MEMBER&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538989124&lt;/td&gt; &lt;td&gt;DR &lt;/td&gt; &lt;td&gt;DROP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;541284164&lt;/td&gt; &lt;td&gt;DWC &lt;/td&gt; &lt;td&gt;DENY WITH CASCADE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538990661&lt;/td&gt; &lt;td&gt;EX &lt;/td&gt; &lt;td&gt;EXECUTE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538989638&lt;/td&gt; &lt;td&gt;FT &lt;/td&gt; &lt;td&gt;FULLTEXT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;541545542&lt;/td&gt; &lt;td&gt;FTG &lt;/td&gt; &lt;td&gt;FULLTEXT_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538976327&lt;/td&gt; &lt;td&gt;G &lt;/td&gt; &lt;td&gt;GRANT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1111773767&lt;/td&gt; &lt;td&gt;GRDB&lt;/td&gt; &lt;td&gt;DATABASE_PERMISSION_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1329877575&lt;/td&gt; &lt;td&gt;GRDO&lt;/td&gt; &lt;td&gt;DATABASE_OBJECT_PERMISSION_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;542069319&lt;/td&gt; &lt;td&gt;GRO &lt;/td&gt; &lt;td&gt;SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1330860615&lt;/td&gt; &lt;td&gt;GRSO&lt;/td&gt; &lt;td&gt;SERVER_OBJECT_PERMISSION_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1448301127&lt;/td&gt; &lt;td&gt;GRSV&lt;/td&gt; &lt;td&gt;SERVER_PERMISSION_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;541546311&lt;/td&gt; &lt;td&gt;GWG &lt;/td&gt; &lt;td&gt;GRANT WITH GRANT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1346653513&lt;/td&gt; &lt;td&gt;IMDP&lt;/td&gt; &lt;td&gt;DATABASE_PRINCIPAL_IMPERSONATION_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;542133577&lt;/td&gt; &lt;td&gt;IMP &lt;/td&gt; &lt;td&gt;IMPERSONATE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1347636553&lt;/td&gt; &lt;td&gt;IMSP&lt;/td&gt; &lt;td&gt;SERVER_PRINCIPAL_IMPERSONATION_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538988105&lt;/td&gt; &lt;td&gt;IN &lt;/td&gt; &lt;td&gt;INSERT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;541214540&lt;/td&gt; &lt;td&gt;LGB &lt;/td&gt; &lt;td&gt;BROKER LOGIN&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1195525964&lt;/td&gt; &lt;td&gt;LGBG&lt;/td&gt; &lt;td&gt;BROKER_LOGIN_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1094993740&lt;/td&gt; &lt;td&gt;LGDA&lt;/td&gt; &lt;td&gt;DISABLE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1111770956&lt;/td&gt; &lt;td&gt;LGDB&lt;/td&gt; &lt;td&gt;CHANGE DEFAULT DATABASE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1095059276&lt;/td&gt; &lt;td&gt;LGEA&lt;/td&gt; &lt;td&gt;ENABLE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1279674188&lt;/td&gt; &lt;td&gt;LGFL&lt;/td&gt; &lt;td&gt;FAILED_LOGIN_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1179207500&lt;/td&gt; &lt;td&gt;LGIF&lt;/td&gt; &lt;td&gt;LOGIN FAILED&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1397311308&lt;/td&gt; &lt;td&gt;LGIS&lt;/td&gt; &lt;td&gt;LOGIN SUCCEEDED&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1196181324&lt;/td&gt; &lt;td&gt;LGLG&lt;/td&gt; &lt;td&gt;CHANGE DEFAULT LANGUAGE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;541935436&lt;/td&gt; &lt;td&gt;LGM &lt;/td&gt; &lt;td&gt;DATABASE MIRRORING LOGIN&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1196246860&lt;/td&gt; &lt;td&gt;LGMG&lt;/td&gt; &lt;td&gt;DATABASE_MIRRORING_LOGIN_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1296975692&lt;/td&gt; &lt;td&gt;LGNM&lt;/td&gt; &lt;td&gt;NAME CHANGE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;542066508&lt;/td&gt; &lt;td&gt;LGO &lt;/td&gt; &lt;td&gt;LOGOUT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1146308428&lt;/td&gt; &lt;td&gt;LGSD&lt;/td&gt; &lt;td&gt;SUCCESSFUL_LOGIN_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538988364&lt;/td&gt; &lt;td&gt;LO &lt;/td&gt; &lt;td&gt;LOGOUT_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1111772749&lt;/td&gt; &lt;td&gt;MNDB&lt;/td&gt; &lt;td&gt;DATABASE_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1329876557&lt;/td&gt; &lt;td&gt;MNDO&lt;/td&gt; &lt;td&gt;DATABASE_OBJECT_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1346653773&lt;/td&gt; &lt;td&gt;MNDP&lt;/td&gt; &lt;td&gt;DATABASE_PRINCIPAL_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;542068301&lt;/td&gt; &lt;td&gt;MNO &lt;/td&gt; &lt;td&gt;SCHEMA_OBJECT_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1330859597&lt;/td&gt; &lt;td&gt;MNSO&lt;/td&gt; &lt;td&gt;SERVER_OBJECT_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1347636813&lt;/td&gt; &lt;td&gt;MNSP&lt;/td&gt; &lt;td&gt;SERVER_PRINCIPAL_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1196182862&lt;/td&gt; &lt;td&gt;NMLG&lt;/td&gt; &lt;td&gt;NO CREDENTIAL MAP TO LOGIN&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538988623&lt;/td&gt; &lt;td&gt;OP &lt;/td&gt; &lt;td&gt;OPEN&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1111773263&lt;/td&gt; &lt;td&gt;OPDB&lt;/td&gt; &lt;td&gt;DATABASE_OPERATION_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1448300623&lt;/td&gt; &lt;td&gt;OPSV&lt;/td&gt; &lt;td&gt;SERVER_OPERATION_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1380013904&lt;/td&gt; &lt;td&gt;PWAR&lt;/td&gt; &lt;td&gt;APPLICATION_ROLE_CHANGE_PASSWORD_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;541284176&lt;/td&gt; &lt;td&gt;PWC &lt;/td&gt; &lt;td&gt;CHANGE PASSWORD&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1195595600&lt;/td&gt; &lt;td&gt;PWCG&lt;/td&gt; &lt;td&gt;LOGIN_CHANGE_PASSWORD_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1396922192&lt;/td&gt; &lt;td&gt;PWCS&lt;/td&gt; &lt;td&gt;CHANGE OWN PASSWORD&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1480939344&lt;/td&gt; &lt;td&gt;PWEX&lt;/td&gt; &lt;td&gt;PASSWORD EXPIRATION&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1129142096&lt;/td&gt; &lt;td&gt;PWMC&lt;/td&gt; &lt;td&gt;MUST CHANGE PASSWORD&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1280333648&lt;/td&gt; &lt;td&gt;PWPL&lt;/td&gt; &lt;td&gt;PASSWORD POLICY&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;542267216&lt;/td&gt; &lt;td&gt;PWR &lt;/td&gt; &lt;td&gt;RESET PASSWORD&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1397905232&lt;/td&gt; &lt;td&gt;PWRS&lt;/td&gt; &lt;td&gt;RESET OWN PASSWORD&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;542463824&lt;/td&gt; &lt;td&gt;PWU &lt;/td&gt; &lt;td&gt;UNLOCK ACCOUNT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538976338&lt;/td&gt; &lt;td&gt;R &lt;/td&gt; &lt;td&gt;REVOKE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538985298&lt;/td&gt; &lt;td&gt;RC &lt;/td&gt; &lt;td&gt;RECEIVE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538986066&lt;/td&gt; &lt;td&gt;RF &lt;/td&gt; &lt;td&gt;REFERENCES&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538989394&lt;/td&gt; &lt;td&gt;RS &lt;/td&gt; &lt;td&gt;RESTORE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;541284178&lt;/td&gt; &lt;td&gt;RWC &lt;/td&gt; &lt;td&gt;REVOKE WITH CASCADE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;541546322&lt;/td&gt; &lt;td&gt;RWG &lt;/td&gt; &lt;td&gt;REVOKE WITH GRANT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538987603&lt;/td&gt; &lt;td&gt;SL &lt;/td&gt; &lt;td&gt;SELECT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538988115&lt;/td&gt; &lt;td&gt;SN &lt;/td&gt; &lt;td&gt;SEND&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1313624147&lt;/td&gt; &lt;td&gt;SPLN&lt;/td&gt; &lt;td&gt;SHOW PLAN&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1448301651&lt;/td&gt; &lt;td&gt;STSV&lt;/td&gt; &lt;td&gt;SERVER_STATE_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1313953107&lt;/td&gt; &lt;td&gt;SUQN&lt;/td&gt; &lt;td&gt;SUBSCRIBE QUERY NOTIFICATION&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1313035859&lt;/td&gt; &lt;td&gt;SVCN&lt;/td&gt; &lt;td&gt;SERVER CONTINUE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1146115667&lt;/td&gt; &lt;td&gt;SVPD&lt;/td&gt; &lt;td&gt;SERVER PAUSED&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1146312275&lt;/td&gt; &lt;td&gt;SVSD&lt;/td&gt; &lt;td&gt;SERVER SHUTDOWN&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1381193299&lt;/td&gt; &lt;td&gt;SVSR&lt;/td&gt; &lt;td&gt;SERVER STARTED&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1095975252&lt;/td&gt; &lt;td&gt;TASA&lt;/td&gt; &lt;td&gt;TRACE AUDIT START&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1347633492&lt;/td&gt; &lt;td&gt;TASP&lt;/td&gt; &lt;td&gt;TRACE AUDIT STOP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538988372&lt;/td&gt; &lt;td&gt;TO &lt;/td&gt; &lt;td&gt;TAKE OWNERSHIP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1111773012&lt;/td&gt; &lt;td&gt;TODB&lt;/td&gt; &lt;td&gt;DATABASE_OWNERSHIP_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1329876820&lt;/td&gt; &lt;td&gt;TODO&lt;/td&gt; &lt;td&gt;DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;542068564&lt;/td&gt; &lt;td&gt;TOO &lt;/td&gt; &lt;td&gt;SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1330859860&lt;/td&gt; &lt;td&gt;TOSO&lt;/td&gt; &lt;td&gt;SERVER_OBJECT_OWNERSHIP_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1195594324&lt;/td&gt; &lt;td&gt;TRCG&lt;/td&gt; &lt;td&gt;TRACE_CHANGE_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;542069332&lt;/td&gt; &lt;td&gt;TRO &lt;/td&gt; &lt;td&gt;TRANSFER&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1346847573&lt;/td&gt; &lt;td&gt;UCGP&lt;/td&gt; &lt;td&gt;USER_CHANGE_PASSWORD_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1195459669&lt;/td&gt; &lt;td&gt;UDAG&lt;/td&gt; &lt;td&gt;USER_DEFINED_AUDIT_GROUP&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1430340693&lt;/td&gt; &lt;td&gt;UDAU&lt;/td&gt; &lt;td&gt;USER DEFINED AUDIT&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538988629&lt;/td&gt; &lt;td&gt;UP &lt;/td&gt; &lt;td&gt;UPDATE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1178686293&lt;/td&gt; &lt;td&gt;USAF&lt;/td&gt; &lt;td&gt;CHANGE USERS LOGIN AUTO&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1196184405&lt;/td&gt; &lt;td&gt;USLG&lt;/td&gt; &lt;td&gt;CHANGE USERS LOGIN&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1129599829&lt;/td&gt; &lt;td&gt;USTC&lt;/td&gt; &lt;td&gt;COPY PASSWORD&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1414743126&lt;/td&gt; &lt;td&gt;VDST&lt;/td&gt; &lt;td&gt;VIEW DATABASE STATE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1414746966&lt;/td&gt; &lt;td&gt;VSST&lt;/td&gt; &lt;td&gt;VIEW SERVER STATE&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1413699414&lt;/td&gt; &lt;td&gt;VWCT&lt;/td&gt; &lt;td&gt;VIEW CHANGETRACKING&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538984792&lt;/td&gt; &lt;td&gt;XA &lt;/td&gt; &lt;td&gt;EXTERNAL ACCESS ASSEMBLY&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;538989912&lt;/td&gt; &lt;td&gt;XU &lt;/td&gt; &lt;td&gt;UNSAFE ASSEMBLY&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://schottsql.blogspot.com/2016/02/sql-server-audits-and-actionids.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-6089132727942879117</guid><pubDate>Sun, 16 Aug 2015 00:05:00 +0000</pubDate><atom:updated>2017-03-08T09:26:24.839-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SSDT</category><title>Database Lifecycle Management - Dacpacs</title><description>I came across an excellent article recently @ Simple-Talk discussing Dacpacs, working with them, structures, etc. in quite a bit of detail for a short article. This post discuses benefits, drawbacks, and potential areas of concern for working with dacpacs for your database management.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://www.simple-talk.com/sql/database-delivery/microsoft-and-database-lifecycle-management-dlm-the-dacpac/&quot;&gt;https://www.simple-talk.com/sql/database-delivery/microsoft-and-database-lifecycle-management-dlm-the-dacpac/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The PowerShell scripts are well worth checking out and there are several interesting calls for SQLPackage along the way. I appreciated his findings with some of the issues - not always seeing changes that should be detected. I suspect that there&#39;s a setting not configured properly there, but couldn&#39;t say for sure. I know that I haven&#39;t hit any issues when using SQLPackage and dacpacs for normal DB development of the sort discovered at the end of the article.&lt;br /&gt;
&lt;br /&gt;
The conclusion is spot on, whatever solution you use - check your scripts, test, and verify before just putting the solution into production.</description><link>http://schottsql.blogspot.com/2015/08/database-lifecycle-management-dacpacs.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-2252770891240470603</guid><pubDate>Mon, 20 Jul 2015 18:31:00 +0000</pubDate><atom:updated>2015-07-20T13:31:30.954-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SSDT</category><title>Pre-deploy SQL Scripts before checking for changes</title><description>I just came across a post from Ed Elliot (&lt;a href=&quot;https://the.agilesql.club/blogs/Ed-Elliott&quot; target=&quot;_blank&quot;&gt;b&lt;/a&gt; | &lt;a href=&quot;https://twitter.com/EdDebug&quot; target=&quot;_blank&quot;&gt;t&lt;/a&gt; ) about running Scripts before the SQL Package process runs. Sort of a &quot;Pre&quot; Pre-deploy script.&amp;nbsp; The concept is simple enough, but it&#39;s something people have wanted for a while.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://the.agilesql.club/Blog/Ed-Elliott/Pre-Compare-and-Pre-Deploy-Scripts-In-SSDT&quot; target=&quot;_blank&quot;&gt;Here&#39;s the main article.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The general idea is that you add a SQL Script to your project with:&lt;br /&gt;
Build Action = &quot;None&quot;&lt;br /&gt;
Copy To Directory = &quot;Copy Always&quot; (or &quot;Copy if Newer&quot;)&lt;br /&gt;
&lt;br /&gt;
When you set up your publish actions, look for this script first, run it in PowerShell, SQLCMD, or whatever other option you might have, then run your SQLPackage commands as normal. It will run through whatever scripts you want to run first, then compare against the modified database to bring it up to date.&lt;br /&gt;
&lt;br /&gt;
The idea is pretty clever, though I haven&#39;t come across a lot of need for it when trying to deploy DB changes. I&#39;m not quite comfortable with a script running to change the state of the database to something unknown prior to running the script to bring it in line with version control. I suppose it has some use-cases, though, as I&#39;ve come across this request several times on Stack Overflow.</description><link>http://schottsql.blogspot.com/2015/07/pre-deploy-sql-scripts-before-checking.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-3534990899346498414</guid><pubDate>Fri, 07 Nov 2014 19:09:00 +0000</pubDate><atom:updated>2014-11-07T13:09:42.078-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Excel</category><category domain="http://www.blogger.com/atom/ns#">Powerpivot</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSAS</category><title>SSAS Tabular and Excel PowerPivot</title><description>&lt;p&gt;I don’t know why it took so long before making the connection between PowerPivot models and SSAS Tabular models, but in the last couple of days I came across several blogs and videos tying the two together. With that in mind, I took the plunge into PowerPivot and built a quick model off of some SQL queries to test out a concept.&lt;/p&gt; &lt;p&gt;I started with the basics of mocking up a fact table. I stripped out decorator text, “renamed” a couple of columns in the query, filtered the data so I wouldn’t pull back a crazy amount into my local workstation, verified the counts and look of the data in a SQL query, and added that. Excel quickly loaded 1.2M rows and didn’t blink.&lt;/p&gt; &lt;p&gt;After that, I knew I needed a couple of Dimension-like tables. I wrote queries for those in a similar fashion and added the data again. Each addition went smoothly. I was able to add the proper relationships quickly to tie everything together.&lt;/p&gt; &lt;p&gt;To finalize the model, I created a couple of hierarchies to make querying easier. After messing around with these several times in SSAS Multi-Dimensional, I was shocked at how easy it was to create a hierarchy for dates and even certain domain-specific entries in our data: Right-click, create new hierarchy, drag and drop columns. Done.&lt;/p&gt; &lt;p&gt;After the model was finished, I dropped the relevant fact data into a Pivot Table and could easily analyze the data in all sorts of interesting ways. I worked around this with OLAP for quite some time to come up with a similar concept. With PowerPivot, I wrote a couple of queries, linked the tables, and had something workable within an hour. As an added benefit, I know I can scale that up to an SSAS server without too much trouble and have a similar experience.&lt;/p&gt; &lt;p&gt;Hat tip to the folks @ &lt;a href=&quot;http://www.powerpivotpro.com&quot;&gt;www.powerpivotpro.com&lt;/a&gt; and &lt;a href=&quot;http://www.sqlbi.com&quot;&gt;www.sqlbi.com&lt;/a&gt; for the many articles and pointers to get me started and over that initial hump.&lt;/p&gt;  </description><link>http://schottsql.blogspot.com/2014/11/ssas-tabular-and-excel-powerpivot.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-3560515426720823954</guid><pubDate>Fri, 26 Sep 2014 13:32:00 +0000</pubDate><atom:updated>2014-09-26T08:58:49.481-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">BIML</category><category domain="http://www.blogger.com/atom/ns#">SSIS</category><title>Exploring BIML</title><description>&lt;h3&gt;Getting Started&lt;/h3&gt; &lt;p&gt;I attended Varigence’s BIML Workshop last year prior to the PASS conference and got to learn a little BIML while seeing what it can do. Recently, I realized that I had a job to do that required applying the same SSIS ETL to several different sets of tables in our system. I figured this would be a great time to put some of that BIML into use.&lt;/p&gt; &lt;p&gt;To get started, you’ll need either the &lt;a href=&quot;http://bidshelper.codeplex.com/&quot; target=&quot;_blank&quot;&gt;BIDS Helper&lt;/a&gt; add-on or a copy of &lt;a href=&quot;http://varigence.com/Products/Mist/Capabilities&quot; target=&quot;_blank&quot;&gt;Varigence’s Mist&lt;/a&gt;. While Mist is an excellent tool, it’s also priced towards the people who are really working with BIML and not targeted at those who aren’t quite ready to justify the cost. ($249/month or $3999 at the time I’m writing this – worth it if you use a lot of BIML, but not for everyone)&lt;/p&gt; &lt;p&gt;I made sure my BIDS Helper bits were up to date, started a new SSIS Project, and added a new BIML file by right-clicking the project and selecting “Add New BIML File”. After that I followed a couple of excellent walkthroughs and tutorials to get me started and refresh my memory. To name a couple of sources:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Andy Leonard’s &lt;a href=&quot;http://www.sqlservercentral.com/stairway/100550/&quot; target=&quot;_blank&quot;&gt;Stairway to BIML&lt;/a&gt; articles at SQL Server Central  &lt;li&gt;Scott Currie’s &lt;a href=&quot;http://bimlscript.com/Walkthrough/Details/73&quot; target=&quot;_blank&quot;&gt;Create and Load a Staging Environment from Scratch in an Hour With BIML&lt;/a&gt;  &lt;li&gt;Paul S. Water’s Getting Started and Basic BIMLScript Structure walkthroughs at the &lt;a href=&quot;http://bimlscript.com/Browse/Walkthroughs&quot; target=&quot;_blank&quot;&gt;BimlScript.com site’s Walkthrough page&lt;/a&gt;.  &lt;li&gt;The helpful people who frequent the &lt;a href=&quot;http://varigence.com/Forums?forumName=Biml&quot; target=&quot;_blank&quot;&gt;Varigence BIML forums&lt;/a&gt;  &lt;li&gt;David Stein (&lt;a href=&quot;http://www.made2mentor.com/&quot; target=&quot;_blank&quot;&gt;b&lt;/a&gt; | &lt;a href=&quot;https://twitter.com/Made2Mentor&quot; target=&quot;_blank&quot;&gt;t&lt;/a&gt;) for letting me bounce some ideas off of him&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h3&gt;Challenges&lt;/h3&gt; &lt;p&gt;1. Actually getting my connection string correct. I don’t often type in connection strings so hit the ConnectionStrings.com website for SQL OLEDB connections. That told me to use this format for my connect strings:&lt;/p&gt; &lt;p&gt;&lt;code&gt;Provider=SQLNCLI11;Server=myServerAddress;Database=myDataBase;&lt;br&gt;Trusted_Connection=yes;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Regardless of what I tried, this refused to connect as expected. I eventually changed back to the older syntax and that worked:&lt;/p&gt; &lt;p&gt;&lt;code&gt;Provider=SQLNCLI11;Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=True;&lt;/code&gt;  &lt;p&gt;Not a huge deal, but this was giving me fits with my connections with either security issues or having to specify DB Names in my code.  &lt;p&gt;&amp;nbsp; &lt;p&gt;2. Next up – not knowing C# or BIML very well. Nothing for this except time and practice. :-)&amp;nbsp; I got better along the way, slowly catching things as I typed them in and having some feel for what would happen.  &lt;p&gt;&amp;nbsp; &lt;p&gt;3. For some reason, my Intellisense completely stopped working at one point. It worked for everything prior to when I added my “import” lines for various namespaces, but anything after that wouldn’t work at all. I got around this a little by using the &lt;a href=&quot;http://bimlscript.com/Develop&quot; target=&quot;_blank&quot;&gt;BimlScript Editor&lt;/a&gt; online to check some code, but obviously this doesn’t work when you’re importing local columns. I never did get this working but also haven’t tried to reproduce it with a new project. &lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; It seems that if I move my @ Import statements &lt;em&gt;before&lt;/em&gt; I open the first BIML tag in the XML, my intellisense works again. Putting the statements within the Biml section is perfectly valid, but putting them at the top/beginning of the file before I start writing Biml makes a lot more sense and results in Intellisense working again. This would have made my life easier. &lt;p&gt;&amp;nbsp; &lt;p&gt;4. The last major challenge this time through was trying to get BIML to generate a logical “AND” in the SSIS expression I wanted to use. I typed it in, used “&amp;amp;&amp;amp;” for my AND statement, and checked syntax. I repeatedly got errors about syntax. The first time around, I figured my expression might be too long. It was and I broke it apart only to get the same error. I looked at the string generated using some MessageBox.Show() hacks and it looked okay. I finally came across a tip indicating that BIML doesn’t work well with the “&amp;amp;” character. The suggestion was to replace that with “&amp;amp;amp;” whenever you wanted to output an ampersand as part of the expression. This worked well and my package was generated.  &lt;p&gt;&amp;nbsp; &lt;h3&gt;Next&lt;/h3&gt; &lt;p&gt;I still need to tweak my package. I have more tables to import from a different source on the same server, but targeting a single database on my destination server. I need to figure out tiers and included files to better reuse and organize code. I’d love to get the correct connections going so BIML and SSIS read the correct column data types, especially when it comes to BLOB data columns. I need to rework some of the package components to better adhere to best practices. Overall it’s been an interesting ride trying to figure these things out and while it may not have saved time with this particular project, I’ll be able to use the lessons learned for my next project.&lt;/p&gt;  </description><link>http://schottsql.blogspot.com/2014/09/exploring-biml.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-1673643035268121086</guid><pubDate>Tue, 26 Aug 2014 18:04:00 +0000</pubDate><atom:updated>2014-08-26T13:04:09.682-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#">VSTS DB Pro</category><title>SQL Projects &amp;amp; Change Data Capture</title><description>&lt;p&gt;I ran across this article from &lt;a href=&quot;http://MSSQLTips.com&quot; target=&quot;_blank&quot;&gt;MSSQLTips.com&lt;/a&gt; discussing the use of CDC with SQL Projects. We don’t use CDC with our current systems so I’d never tried to investigate this, but I would also have expected better support out of the box. In the meantime, Ray Barley wrote up a good article on enabling CDC for the Database and then using post-deploy scripts to enable CDC for tables.&lt;/p&gt; &lt;p&gt;Find the article here: &lt;a href=&quot;http://www.mssqltips.com/sqlservertip/3316/how-to-enable-change-tracking-in-a-sql-server-database-project/&quot; target=&quot;_blank&quot;&gt;www.mssqltips.com/sqlservertip/3316/how-to-enable-change-tracking-in-a-sql-server-database-project/&lt;/a&gt;&lt;/p&gt;  </description><link>http://schottsql.blogspot.com/2014/08/sql-projects-change-data-capture.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-6164758433159486241</guid><pubDate>Mon, 04 Nov 2013 17:42:00 +0000</pubDate><atom:updated>2014-04-22T13:00:40.321-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><title>SSDT Issue–Online Index Option Ignored</title><description>I came across this as we’d recently received a corporate directive that all indexes should be created with the ONLINE=ON option. That’s not too bad. Add that to all indexes as needed, publish the DB project, and we’re good to go. Except that we’re not.&lt;br /&gt;
Due to an issue with SSDT “working as designed”, the ONLINE=ON option is ignored as any of the criteria for comparing indexes within SSDT. On the positive side, it means that any index created that way won’t have the option dropped. On the negative side, it means that any index that is changed or added will not have that option.&lt;br /&gt;
If this is an issue to you, comment and vote on the &lt;a href=&quot;https://www.blogger.com/connect.microsoft.com/SQLServer/feedback/details/775760/ssdt-online-index-option-is-ignored&quot; target=&quot;_blank&quot;&gt;related Connect ticket&lt;/a&gt;. If we can garner enough votes and interest, perhaps MS will hear us and change their mind about whether or not the ONLINE=ON should be part of the release script.&lt;br /&gt;
In the meantime, if you absolutely need this functionality, generate scripts for your releases and ensure that all index creates/alters include the option you want.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Edit&lt;/b&gt;: There&#39;s been some discussion about this on the MSDN forums around this. Kevin Cunnane posted several responses pointing to a Codeplex example of how this might be possible by compiling a DLL and referencing that through the SQLPackage command line. I have not had a chance to try that out yet, but am including the forum and Codeplex links for those who want to investigate further.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://social.msdn.microsoft.com/Forums/sqlserver/en-US/959091e3-0530-49e1-bba6-a4c28e274330/visual-studio-2012-publishing-issue?forum=ssdt&quot; target=&quot;_blank&quot;&gt;Forum post&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://dacsamples.codeplex.com/SourceControl/latest#Samples/Contributors/CreateIndexOperationalPropsModifier.cs&quot; target=&quot;_blank&quot;&gt;Codeplex example&lt;/a&gt; </description><link>http://schottsql.blogspot.com/2013/11/ssdt-issueonline-index-option-ignored.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-2179194044123007427</guid><pubDate>Tue, 22 Oct 2013 17:28:00 +0000</pubDate><atom:updated>2016-03-28T15:31:43.459-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><title>All SSDT Articles</title><description>&lt;!-- Recent Posts by Label Start --&gt;&lt;br /&gt;
&lt;!-- code by BloggerSentral.com --&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function recentpostslist(json) {
 document.write(&#39;&lt;ul&gt;&#39;);
 for (var i = 0; i &lt; json.feed.entry.length; i++)
 {
    for (var j = 0; j &lt; json.feed.entry[i].link.length; j++) {
      if (json.feed.entry[i].link[j].rel == &#39;alternate&#39;) {
        break;
      }
    }
var entryUrl = &quot;&#39;&quot; + json.feed.entry[i].link[j].href + &quot;&#39;&quot;;//bs
var entryTitle = json.feed.entry[i].title.$t;
var item = &quot;&lt;li&gt;&quot; + &quot;&lt;a href=&quot;+ entryUrl + &#39;&quot; target=&quot;_blank&quot;&gt;&#39; + entryTitle + &quot;&lt;/a&gt; &lt;/li&gt;
&quot;;
 document.write(item);
 }
 document.write(&#39;&lt;/ul&gt;&#39;);
 }
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://schottsql.blogspot.com/feeds/posts/summary/-/SSDT?max-results=100&amp;alt=json-in-script&amp;callback=recentpostslist&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 80%; float:right;&quot;&gt;Get this &lt;a href=&quot;http://www.bloggersentral.com/2010/04/list-recent-posts-by-label.html&quot;&gt;widget&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;!-- Recent Posts by Label End --&gt;&lt;br /&gt;
</description><link>http://schottsql.blogspot.com/2013/10/all-ssdt-articles.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-6861159180914279078</guid><pubDate>Tue, 22 Oct 2013 16:17:00 +0000</pubDate><atom:updated>2013-10-22T12:28:24.867-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><title>SSDT: Adding Logins for “Execute As”</title><description>&lt;p&gt;We recently encountered an issue requiring us to use “Execute As” syntax in some of our stored procedures. Of course, we have multiple environments which all have different permission definitions so this would cause a bit of an issue. In this case, the login itself is standard in all of our environments, but we don’t define those within the project for the most part.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;First problem:&lt;/strong&gt; Add a new user called “MyLogin” to the project.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; This was easy enough, I just added a new user to the project. However, I then ran into an issue that the &lt;em&gt;Login&lt;/em&gt; for “MyLogin” did not exist in our master.dacpac reference.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Second Problem:&lt;/strong&gt; Create a SQL Login reference within the master dacpac file that could be seen by all of our projects.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; This proved to be a bit trickier. The model.xml file inside the default master.dacpac files contains many system-level objects. We would need to find the appropriate XML syntax for a new SQL Login element, add it to the model.xml file, and then update the hash for the dacpac file.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Extract the Model.xml file from our master.dacpac file&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;This can be easily done by finding your master.dacpac file that you referenced in your project and either renaming it to a .zip file or using a tool such as &lt;a href=&quot;http://7-zip.org/&quot; target=&quot;_blank&quot;&gt;7-zip&lt;/a&gt; to right-click the file and open it. Extract its “model.xml” file to some working folder.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Add a new SQL Login element to the model.xml file&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Now that there’s a copy of model.xml to edit, open it in your favorite XML or Text editor. I like Notepad++, but even plain Notepad will work. Navigate to the very bottom of the file. We want to add the new element just before the &amp;lt;/Model&amp;gt; tag. (for ease of use, not a requirement) The example XML is below. Note the “GloballyScoped” annotation type. This treats the entity as something that is available outside of the current database.&lt;/p&gt;&lt;pre&gt;&amp;lt;Element Type=&quot;SqlLogin&quot; Name=&quot;[MyLogin]&quot;&amp;gt;
&amp;lt;Property Name=&quot;Password&quot; Value=&quot;MyPassword&quot; /&amp;gt;
&amp;lt;Annotation Type=&quot;GloballyScoped&quot; /&amp;gt;
&amp;lt;/Element&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;&lt;property name=&quot;Password&quot; value=&quot;jwOfxRt%hre=grexdn%{#Aw&amp;gt;msFT7_&amp;amp;#$!~&amp;lt;1|v|Z ySock5&quot;&gt;&lt;strong&gt;Make a new Dacpac file&lt;/strong&gt;&lt;/property&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;property name=&quot;Password&quot; value=&quot;jwOfxRt%hre=grexdn%{#Aw&amp;gt;msFT7_&amp;amp;#$!~&amp;lt;1|v|Z ySock5&quot;&gt;Now that we’ve added the new login to our model.xml file, either add it back to the existing dacpac file by using something like 7-zip, or re-compress everything that was extracted from the old dacpac into a new zip file, then rename it to master.dacpac.&lt;/property&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;property name=&quot;Password&quot; value=&quot;jwOfxRt%hre=grexdn%{#Aw&amp;gt;msFT7_&amp;amp;#$!~&amp;lt;1|v|Z ySock5&quot;&gt;&lt;strong&gt;But what about the checksum?&lt;/strong&gt;&lt;/property&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;property name=&quot;Password&quot; value=&quot;jwOfxRt%hre=grexdn%{#Aw&amp;gt;msFT7_&amp;amp;#$!~&amp;lt;1|v|Z ySock5&quot;&gt;All of the above works great, but the dacpac files provided by MS all have a checksum associated with them. If that checksum is off, it means that someone tampered with the file and it won’t work when you try to use it as a database reference. I will now give props to Gert Drapers (&lt;a href=&quot;http://www.twitter.com/datadude&quot; target=&quot;_blank&quot;&gt;twitter&lt;/a&gt;) for writing up &lt;a href=&quot;http://sqlproj.com/index.php/2013/02/how-to-add-objects-to-master-dacpac&quot; target=&quot;_blank&quot;&gt;how to add objects to the master.dacpac file&lt;/a&gt;.&lt;/property&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;property name=&quot;Password&quot; value=&quot;jwOfxRt%hre=grexdn%{#Aw&amp;gt;msFT7_&amp;amp;#$!~&amp;lt;1|v|Z ySock5&quot;&gt;To summarize, you basically extract the model.xml, edit it, re-add it to the dacpac, but then you can run a small app Gert wrote called &lt;a href=&quot;https://dl.dropbox.com/u/20239263/SQLProj/Util/dacchksum.zip&quot; target=&quot;_blank&quot;&gt;dacchksum.exe&lt;/a&gt; to modify the checksum. I’m quoting Gert’s article here, but you basically put that exe in a place in your path or in the folder you want to use and run something like this:&lt;/property&gt;&lt;/p&gt;&lt;br /&gt;
&lt;blockquote&gt;&lt;br /&gt;
&lt;p&gt;dacchksum.exe /i:Master.dacpac /u /v&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;p&gt;This will change the checksum of your master.dacpac file so it will now work as a database reference.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;strong&gt;Add your user to the project&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Now that there’s a Login for the user to reference, you can now add the user to the project. Right-click the project, select “Add”, and then choose the “User” option. You’ll have a new User created which you can easily set up to reference the new login in your master file.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Overall, not my favorite way to do these things, but if I know that a login will exist on the server I am more comfortable with adding a user to the project than I would be otherwise. You could still run into issues if this login doesn’t exist everywhere you want to use the project.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;As Gert mentions, this trick is for adding &lt;em&gt;any&lt;/em&gt; object to master. If you have a copy of &lt;a href=&quot;http://sqlblog.com/files/folders/beta/entry42453.aspx&quot; target=&quot;_blank&quot;&gt;sp_whoisactive&lt;/a&gt; or &lt;a href=&quot;http://www.brentozar.com/blitz/&quot; target=&quot;_blank&quot;&gt;sp_blitz&lt;/a&gt; that you want to reference for some reason, you can add them to some one-off project, then copy that XML Element node into your master’s model.xml, regen the hash, and enjoy a new globally referenced object. It’s a useful trick, though one I hope not to have to use very often.&lt;/p&gt;</description><link>http://schottsql.blogspot.com/2013/10/ssdt-adding-logins-for-execute-as.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4845744956082769684.post-3306537805563415618</guid><pubDate>Mon, 23 Sep 2013 23:45:00 +0000</pubDate><atom:updated>2013-09-24T10:25:51.854-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MySQL</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSIS</category><title>SSIS, MySQL, and invalid Dates–Take #2</title><description>&lt;p&gt;A while back I posted &lt;a href=&quot;http://schottsql.blogspot.com/2011/12/tales-of-lazy-dbamysql-ssis-and-0-dates.html&quot; target=&quot;_blank&quot;&gt;an article on handling dates in select statements from MySQL&lt;/a&gt;. The idea was that I wanted a quick way to generate select statements for MySQL that would automatically set any invalid date to NULL. (an invalid date being one such as “0000-00-00” or “1973-02-00”)&amp;nbsp; After some more trial and error, I realized that this script was incomplete. I’ve created an updated script that should better handle those edge cases.&lt;/p&gt; &lt;p&gt;The script is largely the same as the former, but I’ve added handling for invalid years or months or days. We don’t want to redirect the rows for further error handling. We want to treat the dates that won’t successfully import as NULL. This could be done several ways within SSIS, but handling the transform within the select statement reduces our need to write many transforms to handle each date time for each table.&amp;nbsp; (I suspect that BIML could be my friend for this task, but I’m not quite ready to tackle this with BIML.)&lt;/p&gt; &lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Courier New&quot;&gt;&lt;font color=&quot;blue&quot;&gt;SELECT&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#ff0080&quot;&gt;&lt;b&gt;CONCAT&lt;/b&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;blue&quot;&gt;CASE&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot; face=&quot;Courier New&quot;&gt;&lt;br&gt;&lt;font color=&quot;blue&quot;&gt;&amp;nbsp; WHEN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;ordinal_position&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;1&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;THEN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;SELECT &#39;&lt;/font&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;ELSE&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;, &#39;&lt;/font&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp; &lt;font color=&quot;#0000ff&quot;&gt;END&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot; face=&quot;Courier New&quot;&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;CASE&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;data_type&lt;/font&gt; &lt;font color=&quot;blue&quot;&gt;WHEN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;date&#39;&lt;br&gt;&lt;/font&gt;&lt;font color=&quot;blue&quot;&gt;THEN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#ff0080&quot;&gt;&lt;b&gt;CONCAT&lt;/b&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;red&quot;&gt;&#39;CASE WHEN &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;red&quot;&gt;&#39;= &#39;&#39;0000-00-00&#39;&#39; THEN NULL &#39;&lt;br&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;WHEN &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;red&quot;&gt;&#39; LIKE &#39;&#39;%0000%&#39;&#39; THEN NULL &#39;&lt;/font&gt; &lt;br&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;WHEN &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;red&quot;&gt;&#39; LIKE &#39;&#39;%-00%&#39;&#39; THEN NULL &#39;&lt;br&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;, &lt;/font&gt;&lt;font color=&quot;red&quot;&gt;&#39;else &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39; END as &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt; &lt;br&gt;&lt;/font&gt;&lt;font color=&quot;blue&quot;&gt;WHEN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;timestamp&#39;&lt;br&gt;&lt;/font&gt;&lt;font color=&quot;blue&quot;&gt;THEN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#ff0080&quot;&gt;&lt;b&gt;CONCAT&lt;/b&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;red&quot;&gt;&#39;CASE WHEN &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;red&quot;&gt;&#39;= &#39;&#39;0000-00-00&#39;&#39; THEN NULL &#39;&lt;br&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;WHEN &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;red&quot;&gt;&#39; LIKE &#39;&#39;%0000%&#39;&#39; THEN NULL &#39;&lt;/font&gt; &lt;br&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;WHEN &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;red&quot;&gt;&#39; LIKE &#39;&#39;%-00%&#39;&#39; THEN NULL &#39;&lt;br&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;, &lt;/font&gt;&lt;font color=&quot;red&quot;&gt;&#39;else &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39; END as &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt; &lt;font size=&quot;2&quot; face=&quot;Courier New&quot;&gt;&lt;br&gt;&lt;font color=&quot;blue&quot;&gt;WHEN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;time&#39;&lt;br&gt;&lt;/font&gt;&lt;font color=&quot;blue&quot;&gt;THEN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#ff0080&quot;&gt;&lt;b&gt;CONCAT&lt;/b&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;red&quot;&gt;&#39;CAST(&#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;red&quot;&gt;&#39; AS CHAR(8) ) as &#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;maroon&quot;&gt;column_name&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;br&gt;&lt;font color=&quot;blue&quot;&gt;ELSE&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;column_name&lt;br&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;END&lt;/font&gt;&lt;br&gt;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;CASE&lt;/font&gt; &lt;font color=&quot;blue&quot;&gt;WHEN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;ordinal_position&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;&amp;lt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;maxord&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;THEN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;&#39;&lt;/font&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;ELSE&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;#ff0080&quot;&gt;&lt;b&gt;CONCAT&lt;/b&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;red&quot;&gt;&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM MySchema.&#39;&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;c&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;.&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;table_name, &lt;font color=&quot;red&quot;&gt;&#39;;&#39;&lt;/font&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp; &lt;font color=&quot;#0000ff&quot;&gt;END&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;AS&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;Select_Column_Name&lt;/font&gt; &lt;br&gt;&lt;font color=&quot;blue&quot;&gt;FROM&lt;/font&gt;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;maroon&quot;&gt;information_schema&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;.&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;columns&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;AS&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;c&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;JOIN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;blue&quot;&gt;SELECT&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;table_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;br&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;#ff0080&quot;&gt;&lt;b&gt;Max&lt;/b&gt;&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;ordinal_position&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;AS&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;MaxOrd&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;FROM&lt;/font&gt;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;maroon&quot;&gt;information_schema&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;.&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;columns&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;WHERE&lt;/font&gt;&amp;nbsp; &lt;font color=&quot;maroon&quot;&gt;table_schema&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;MySchema&#39;&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;GROUP&lt;/font&gt;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;BY&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;table_name&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;blue&quot;&gt;AS&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;t1&lt;/font&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;ON&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;c&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;.&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;table_name&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;t1&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;.&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;table_name&lt;/font&gt; &lt;br&gt;&lt;font color=&quot;blue&quot;&gt;WHERE&lt;/font&gt;&amp;nbsp; &lt;font color=&quot;maroon&quot;&gt;table_schema&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;MySchema&#39;&lt;/font&gt; &lt;br&gt;&lt;font color=&quot;blue&quot;&gt;ORDER&lt;/font&gt;&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;BY&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;c&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;.&lt;/font&gt;&lt;font color=&quot;maroon&quot;&gt;table_name&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt; &lt;font color=&quot;maroon&quot;&gt;ordinal_position&lt;/font&gt; &lt;br&gt;&lt;font color=&quot;blue&quot;&gt;LIMIT&lt;/font&gt;&amp;nbsp; &lt;font color=&quot;black&quot;&gt;0&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;,&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;black&quot;&gt;50000&lt;/font&gt;&lt;font color=&quot;silver&quot;&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  </description><link>http://schottsql.blogspot.com/2013/09/ssis-mysql-and-invalid-datestake-2.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total></item><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>2022-01-17T09:38:01.946-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">VSTS DB Pro</category><title>SSDT: Setting Different Permissions per Environment</title><description>One of the areas that SSDT doesn&#39;t address adequately is permissions. Many users have different users, logins, and permissions set up across their environments, but SSDT takes a &quot;one size fits all&quot; 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;br /&gt;
Attribution - I&#39;m borrowing heavily from Jamie Thomson&#39;s ( &lt;a href=&quot;http://sqlblog.com/blogs/jamie_thomson/default.aspx&quot; target=&quot;_blank&quot;&gt;blog&lt;/a&gt; | &lt;a href=&quot;https://twitter.com/jamiet&quot; target=&quot;_blank&quot;&gt;twitter&lt;/a&gt; ) post  &lt;br /&gt;
&lt;a href=&quot;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&quot; target=&quot;_blank&quot;&gt;A strategy for managing security for different environments using the Database Development Tools in Visual Studio 2010&lt;/a&gt;  &lt;br /&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 &quot;how to&quot; for SSDT and SQL Projects, but I freely admit that this is based on Jamie&#39;s excellent work.  &lt;br /&gt;
In general, the steps we&#39;ll want to take are:  &lt;br /&gt;
&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;
&lt;li&gt;Generate the files for users/roles/permissions for each database project and environment.  &lt;/li&gt;
&lt;li&gt;Add the files to your SSDT SQL Project  &lt;/li&gt;
&lt;li&gt;Create and set a variable for your environments in your SSDT SQL Project.  &lt;/li&gt;
&lt;li&gt;Adjust your Security Wrapper file to handle your environments.  &lt;/li&gt;
&lt;li&gt;Adjust your post-deploy script to call the Security Wrapper.&lt;/li&gt;
&lt;/ol&gt;
First, let&#39;s look at what happens when you import Permissions by default into an SSDT SQL Project.  &lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJo2I5_LDY2qT2pUhq9scyGtG1xfQwhM6kAETyEe9jl1j6gxUF_bHi2Y9xiu9DVJvckJSPszmESYk5htVaDr5IdPm8e53Mh5s4N4MyAspscHb-Z0ZF032ukaeGv9iu8tN4yqG8iCaHfZg/s1600-h/clip_image001%25255B3%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image001&quot; border=&quot;0&quot; height=&quot;184&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT42tmZ2xuN0JLe21FM0HR6aUTXGuKXN-UnJ9FLxy2WAqanllrcIHUPkqaug2HGMDoxqMQyIVmM45JUtYOsK69MFDrq3VQKVaWMVFxw3fTvjHdWqyMNNBDRAtpGHG-TbpdYZznQMiKYO8/?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; border-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;clip_image001&quot; width=&quot;182&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;
As you can see from the screenshot, we have a &quot;Permissions&quot; file containing granted permissions, a &quot;RoleMemberships&quot; file that adds users to various roles, a &quot;Sales&quot; 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&#39;t and should not be created there because there&#39;s no trust relationship.  &lt;br /&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;br /&gt;
&lt;b&gt;&lt;/b&gt;&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Generate SQL Logins&lt;/b&gt;  &lt;br /&gt;
&lt;a href=&quot;http://support2.microsoft.com/kb/918992&quot; target=&quot;_blank&quot;&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;br /&gt;
&lt;b&gt;&lt;/b&gt;&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Generate the Security Files through PowerShell&lt;/b&gt;  &lt;br /&gt;
First, download the &lt;a href=&quot;https://1drv.ms/u/s!AvsxNXbC2V4opC9Pc6Q9pyNV-Ijd?e=JcvFdY&quot;&gt;PowerShell_CreatePermissions.Zip&lt;/a&gt; file. Extract that to a folder on your hard drive.  &lt;br /&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;br /&gt;
Edit the &quot;GeneratePermissions.ps1&quot; file. Replace the &quot;DB1&quot;, &quot;DB2&quot;, etc with whatever database names you&#39;ll be using. Also uncomment any of the extra lines that you&#39;ll need in the file. (There is likely a better way to do this in Powershell and I&#39;m more than open to some suggestions on how to build up this array in a more concise manner.)  &lt;br /&gt;
The assumption is made that the databasename == the projectname. If that&#39;s not the case, adjust your DB/Project names accordingly.  &lt;br /&gt;
Open a PowerShell prompt in that folder after editing/saving the file.  &lt;br /&gt;
Run the file using something like this commandline:  &lt;br /&gt;
.\GeneratePermissions.ps1 -SQLInstance &quot;localhost&quot; -Environment DEV  &lt;br /&gt;
&quot;localhost&quot; should be replaced with your servername  &lt;br /&gt;
DEV in this case indicates that this will be tied to a variable value of &quot;DEV&quot; when the project is published.  &lt;br /&gt;
I&#39;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;br /&gt;
If you run for several environments, you&#39;ll see a folder structure something like the following for each project (in this case for Adventureworks2012):  &lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6_hIyy7dc-NpG3GfF3ATMF__WqyNHUcDgMMTc_TNhe2vS0MQ0JeLpVyV5w7jnsoTtfCdmGBB1biJ-gUohtdNmTkMWUAcoaFDVcB8QRVC_j3KQAPPfi-nahoRBz0FsAx4EiIcsMB5iMXo/s1600-h/clip_image002%25255B3%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image002&quot; border=&quot;0&quot; height=&quot;155&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbDRnfw_yiH_nZxlEdcNF1lZSFR3EGNY3cb_W8ocLxO_P-bE68usFNZFlI1i6dnoFkZq9hkqQJG5oVjMUIF48TWZATaIX0pylqQnh33Cl6I7RmwffoghHFNQ72sqJEgezp1YJlCCJFEfU/?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; border-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;clip_image002&quot; width=&quot;174&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;
Inside your &quot;SecurityAdditions&quot; folder, you&#39;ll see the following files and folders:  &lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4W4pV-JLRvCW7TX4OxHUpNNw_HMn_TByoPCWp6cwfYe_NaxFXnOMdg98kKIBVWdvU9p2W8-LCsh8vsm_NOfOei1RabFNvGGIjI6N5xxuDsExyFvg-rjkutlBXnk-_Xr9fbmaPv1freG8/s1600-h/clip_image003%25255B3%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image003&quot; border=&quot;0&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikqxT45f2ig-cRX4pz36f5z1HJTasiPNy2SN3EdNn4ynhr_0v7fU8urDuQiCXSE2Epf8nKHxcPZwyfThYzswJBamGyiNuCDEDpxuv8gaQiV2TqWOVzlfvoUk2SoGfSm6_QEnwLHimT-4E/?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; border-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;clip_image003&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;  &lt;br /&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;br /&gt;
Now, let&#39;s add the &quot;SecurityAdditionsWrapper.sql&quot; file from the files we extracted earlier into your &quot;SecurityAdditions&quot; folder. Feel free to edit it as needed to match the environment(s) you want to use for your database project. By default, it&#39;s set to look for the above files plus a &quot;Default&quot; file to be a catch-all. Adjust that so all files/environments match the files you created and save it.  &lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Add the files to your SSDT SQL Project&lt;/b&gt;  &lt;br /&gt;
Copy your newly created folder(s) to the appropriate project. Open each project, and you will notice that the files still don&#39;t show up. Click the project file. You should see a menu item that&#39;s now enabled to &quot;show all files&quot;.  &lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir6RpXLT6eGhAzLqgd_R_9lc7TmjHb3KEw2_vClg51pdqpA-5PcuSHz4i6YAj665d728PMY532CRNHGUFT5ogZBRU9qjmKTPX34uA-o2mSaF3HSRJPWUizFlfZLVwhN7tjFKYNAgM87zc/s1600-h/clip_image004%25255B3%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image004&quot; border=&quot;0&quot; height=&quot;85&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoPZXym6C6_3osxU8iotd_sYFS5d9FSzJT5zLne0Uz_KH-bxWzPuPvGcD1ZoHFWxTKe8OoH_GrxJxYVFW7j1dm7o6zHiZfqS6VMaiETk5hW_JZJI9UOSKyYJgpHM3Dctpj_rddFA67LCQ/?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; border-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;clip_image004&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;
You&#39;ll see a bunch of files that aren&#39;t part of the project under a &quot;Scripts&quot; folder:  &lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNihJx0h0rdSKO8Eu5jToK3_8W0oj04hUELCfHvi_Sng0bLzlKX_hT8c7lUJnGJCEYUB6Q6Q8qwybIdX2KjgrC50pg-Zh4xVlK2m_BvpQIx9H4wODzG_rXxe0IUlVG0YIQvi4p_BAQFnw/s1600-h/clip_image005%25255B3%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image005&quot; border=&quot;0&quot; height=&quot;82&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivIa4Q1iH8UPgOgQnG0-1-79bK3rgdiVycv7yiniopZjvFQzO-QA7aTIxEDD6XHbP32F4MWiEf03AsT2bJThbNsDnaLuyCUXJlq7i1lCbsap-tHP4zB3BN8KQsTZSKzMv9uusrR_Euky0/?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; border-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;clip_image005&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;
We want to add them to the project. Right-click the &quot;Scripts&quot; folder and select the option to &quot;Include in Project&quot;. Click the Project file again and turn off the option to show all files.  &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;We need to set all file properties to &quot;Not in Build&quot; or there will be errors when trying to build the project.&lt;/li&gt;
&lt;/ul&gt;
Unfortunately, we can&#39;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 &quot;Build&quot; to &quot;None&quot;  &lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVoaQi6XB3sfUs-Wrm4cafHUBSmE44gD2IJAoVuQy9N8hSZux2fKVrshnrdHwZV-Zpn6WNvew6rvfHJGcyFLsM8cCulQ4dcN6dNPrW0Rzx1dUzMHuEaevrWWDd04jFc9MrxMiTNA4YHjI/s1600-h/clip_image006%25255B3%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image006&quot; border=&quot;0&quot; height=&quot;94&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEssA8UbPRyxI2HwowoV9TDUfUfSqQTtb7oi4xYkyacLOuhAB0xagXBEDXduJUFRd_RfCP_TdFZTB_qlHXrAWrbqdDwhTvZPtPToUCfsnCKiPNSKxU9UoA2npyyQG3lSM88kALxsBxRS0/?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; border-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;clip_image006&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;
&lt;b&gt;Create and set your Variable to change environments&lt;/b&gt;  &lt;br /&gt;
Open the Project Properties window  &lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSCAVcqB5a2pA2urVy161d-TlVy2wEI58FfuK4y8RrZ3xrx7nZbL1jrpIySx7I8__NblK8eQICAVBfZamDMBtbmJcsCeo2bZ37JJz2GMqnOTU6MFpvfOKHffphPbeslDQw2CAVeQjOvtQ/s1600-h/clip_image007%25255B3%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image007&quot; border=&quot;0&quot; height=&quot;57&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho34WhB3bKCBWL86G-0_78uWSYdGF_kDKh36PbXTP-RfkMncnzRjgBDqJqbJwb87Ddp2Okiiukz7OORdjULo382lMhClpMQGOuPTkpTTXCnA56QNTmkhCjnMo6djt-Er_6rvwxpNpNLXA/?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; border-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;clip_image007&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;
We want to change the SQLCMD variable to add a new variable called &quot;DeployType&quot;. Set it&#39;s default value to &quot;Local&quot; for now, or whatever environment for which you have a set of security scripts.  &lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbIhfNLBY19Z_47InbwAzUj9GjWrdk0k9zWVocZTy9EVICNI3XpJUTDovSFSuaduiUSe6krP3mb2esJ4x-SSbTVEySA4Hq-P6Ga26KdB3p5jlS7KN66_Ksknb819udbad1ewvcTbZkRW4/s1600-h/clip_image008%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image008&quot; border=&quot;0&quot; height=&quot;207&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPfhUuRtpQT3LpQRMKNENbHlVq9fdlh54IRLY5STAhi70UxDORMrprVUUInCDyJh96bgsLluPNyeTlUOx0kgCG84kJnT20e0YZ8DbzIco3d3oVaR_I1Q_DvcXlXXlyl0LRWNRHgeLl7MI/?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;clip_image008&quot; width=&quot;518&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Adjust your Security Wrapper files&lt;/b&gt;  &lt;br /&gt;
The SecurityAdditionsWrapper.sql file in the code set I&#39;ve created comes with settings for &quot;Dev&quot;, &quot;QA&quot;, &quot;Staging&quot;, &quot;Production&quot;, &quot;Local&quot;, and &quot;Default&quot;. It&#39;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&#39;t have a file or set of files, the script will start throwing errors because an expected file doesn&#39;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;br /&gt;
&lt;b&gt;&lt;/b&gt;&amp;nbsp; &lt;br /&gt;
&lt;b&gt;Adjust your Post-Deploy script&lt;/b&gt;  &lt;br /&gt;
Finally, we need to open your Post-Deploy script.  &lt;br /&gt;
Add the following to your script:  &lt;br /&gt;
:r .\SecurityAdditions\SecurityAdditionsWrapper.SQL  &lt;br /&gt;
This will include your SecurityAdditionsWrapper file as part of your post-deploy process. See my earlier post on &lt;a href=&quot;http://schottsql.blogspot.com/2013/05/trick-to-not-run-prepost-sql-on-publish.html&quot;&gt;selectively running pre/post deploy scripts&lt;/a&gt; if you want finer control.    &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;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;
</description><link>http://schottsql.blogspot.com/2013/05/ssdt-setting-different-permissions-per.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT42tmZ2xuN0JLe21FM0HR6aUTXGuKXN-UnJ9FLxy2WAqanllrcIHUPkqaug2HGMDoxqMQyIVmM45JUtYOsK69MFDrq3VQKVaWMVFxw3fTvjHdWqyMNNBDRAtpGHG-TbpdYZznQMiKYO8/s72-c?imgmax=800" height="72" width="72"/><thr:total>15</thr:total></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-10-22T12:28:41.250-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Project</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">VSTS DB Pro</category><title>SSDT: 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=&quot;2&quot; face=&quot;Courier New&quot;&gt;&lt;font color=&quot;green&quot;&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=&quot;blue&quot;&gt;IF&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;(&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;$(DeployType)&#39;&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;silver&quot;&gt;&amp;lt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;New&#39;&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;maroon&quot;&gt;)&lt;/font&gt; &lt;br /&gt;
&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;BEGIN&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;green&quot;&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=&quot;blue&quot;&gt;PRINT&lt;/font&gt;&amp;nbsp;&lt;font color=&quot;red&quot;&gt;&#39;Deploying scripts.&#39;&lt;/font&gt; &lt;br /&gt;
&amp;nbsp; &lt;font color=&quot;blue&quot;&gt;END&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Courier New&quot;&gt;&lt;font color=&quot;green&quot;&gt;&lt;i&gt;--Security - runs last&lt;/i&gt;&lt;/font&gt; &lt;br /&gt;
&lt;font color=&quot;gray&quot;&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;</description><link>http://schottsql.blogspot.com/2013/05/trick-to-not-run-prepost-sql-on-publish.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>4</thr:total></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#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</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&#39;ve added database references to the project. That takes care of all of the &quot;Database.dbo.Object&quot; 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 &quot;DeployType&quot; variable wasn&#39;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=&quot;tr_bq&quot;&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&#39;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.</description><link>http://schottsql.blogspot.com/2013/01/ssdt-publishing-and-referenced-databases.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>2</thr:total></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 &#39;Microsoft.AnalysisServices, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91&#39; 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=&quot;http://forums.asp.net/t/1743386.aspx/1&quot; target=&quot;_blank&quot;&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;  </description><link>http://schottsql.blogspot.com/2012/11/sql-server-problems-with-corrupt-files.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>0</thr:total></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#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</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 &quot;Parameter cannot be null&quot; error for parameter &quot;Key&quot;. This is an internal bug with the product as of at least SQL 2012 CU2. It&#39;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&#39;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 &quot;skipped&quot; 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=&quot;http://social.msdn.microsoft.com/Forums/en-US/ssdt/thread/ceeaf961-fe8e-430a-99b7-c83ff9de77c3&quot;&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;  </description><link>http://schottsql.blogspot.com/2012/11/ssdt-tips-tricks-and-gotchas.html</link><author>noreply@blogger.com (Peter Schott)</author><thr:total>2</thr:total></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#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</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 &quot;Snapshot Project&quot;. &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4syvKaxhXP4I9PdSMn0hILFGvsjnFDFo73ErjDUazRl4QjfsiLNCHIUiHM36VL30X5VeutwrPN4e_jOInZzKonr_MTm5M05HoxZs16icbd4Lhlocdb3LjAjpffxa9iZadnH5ZsZg70ew/s1600-h/clip_image001%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image001&quot; border=&quot;0&quot; height=&quot;71&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3FdwibqfIzw40Sssp15zEOLJdZAA0iKpQdHln3wRNc16fqgjVKNwwFmhjhnyKoDUtxTo67PHReVXu2qJeDNAN4-cW7u2dGyIHyLgSIlgb0PYOaTo2cBE5l-hN2hZsBjudBmn_LpHt9Vg/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image001&quot; width=&quot;269&quot; /&gt;&lt;/a&gt;&lt;/blockquote&gt;
This builds a dacpac file into a folder within the project called &quot;Snapshots&quot; 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;
</description><link>http://schottsql.blogspot.com/2012/11/ssdt-sql-project-snapshots.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3FdwibqfIzw40Sssp15zEOLJdZAA0iKpQdHln3wRNc16fqgjVKNwwFmhjhnyKoDUtxTo67PHReVXu2qJeDNAN4-cW7u2dGyIHyLgSIlgb0PYOaTo2cBE5l-hN2hZsBjudBmn_LpHt9Vg/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></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#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">SSIS</category><category domain="http://www.blogger.com/atom/ns#">Version Control</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 &quot;Build&quot;. &lt;blockquote&gt; &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEXIsC1oIWg4v-uUinclqHkoH15WapU8VfISBcgcY-cyzGiD9G3huc8F7HbWFqWo_QKpTwqBWZjHSV4liqXhEK_qxksa0L-_2L4iOmAjeVYBPHxNCGPpirC-kGnE5EyZiIUc3DGd1VZrY/s1600-h/clip_image001%25255B4%25255D.png&quot;&gt;&lt;img title=&quot;clip_image001&quot; style=&quot;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&quot; border=&quot;0&quot; alt=&quot;clip_image001&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI3UV0nXzRtB31FoB65bSwOoz_xlCycoKvYAAfF48ox8uY9ThilqWxS1Kslrt0eswtDJWFrpebRAa3HxcPxSYEJOVWx5Lnt05dHUK-2MH9euZ_qMkmdj-ldgBcIZgttGN58pfPH-oxCgA/?imgmax=800&quot; width=&quot;359&quot; height=&quot;174&quot;&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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWNCt0b1rBx8arzF56sFyGJ2Q5Y9qtfaoOxMlCII6IhmgKbsMqAdAshNC5vJ_59CJ1reY43sxXz7DDze1gswaJLfkMCd3kTg0GWU35ry6XPxfXiA1un4_8Lqc4hWJyM89yJETw9TB6ZKI/s1600-h/clip_image002%25255B5%25255D.png&quot;&gt;&lt;img title=&quot;clip_image002&quot; style=&quot;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&quot; border=&quot;0&quot; alt=&quot;clip_image002&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBQVjgqG8OXeG82fkUBscL0nZtH0kNgCXFJlzxRV3MLk-2ziIXEFBvYV-MhR_M3QmFBZvlRMIR4XBJy6rjLT2pggNSLfWIqfqv9BJjxdyHYQRde5K9TPbOV_E1PsxNHRHuf-q5Pdbk6SU/?imgmax=800&quot; width=&quot;612&quot; height=&quot;411&quot;&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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT84cW78QFsKuyCjhKTBysp2hapDDN3AhedDvDP8BfKk_gXwAirhLBKWNIk4klRET0en-r4mJnpn2s_egLGih2TBKa5Q1kaJ9nDVSA7_7Agq0KzHGILy3JqRhYYVAFSeQW0Hu0BhkkJXQ/s1600-h/clip_image003%25255B4%25255D.png&quot;&gt;&lt;img title=&quot;clip_image003&quot; style=&quot;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&quot; border=&quot;0&quot; alt=&quot;clip_image003&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1NkbSLIdRoiSo5emQ9cF4vZCNz4A47dqGyaOHtaoKkFlI9s1c_VITZwf-Iazj4bbTXZ4JxeHzNI8aTDmFUxtVy_4N_88TCN2J6PSwiWMnX86634JQ8CSn35fLqcl-W1YZ_94mAFdvuD0/?imgmax=800&quot; width=&quot;597&quot; height=&quot;298&quot;&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 &quot;Save Profile As&quot; option to save this to a location within your project. Selecting the &quot;Add profile to project&quot; 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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixN5jPme2JZwmhPsDIQPuc-qjuY2MXHnXNU0aKJbqhUJeoEWkwR3qBG5Vm9VMb5HxI-3WT2IqqDlY0k3UPPE1wSB3mZGV8QCUeSZQPJ6WTbBUyMxYb-u7LKhZtToq0xXfbloN47Rqk0yM/s1600-h/clip_image004%25255B4%25255D.png&quot;&gt;&lt;img title=&quot;clip_image004&quot; style=&quot;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&quot; border=&quot;0&quot; alt=&quot;clip_image004&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd-e-Vyu6IXERJtsIF-DZAth6ikRAOOOdPJ8ZedIs0_0X-wy6LBULnmBF9mfdPjWGTfJAy07wPlj7eJ4j7ZbG2q63nvqfdwP5LB1nvTQeaznHcfunFWT46_wa698MdknNDO4hVqqSh6po/?imgmax=800&quot; width=&quot;600&quot; height=&quot;449&quot;&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;&quot;Always re-create database&quot; - this will re-create the database. Any data in the database will be lost. &lt;li&gt;&quot;Block incremental deployment if data loss might occur&quot; - 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;&quot;DROP objects in target but not in project&quot; - This will remove anything in the database that doesn&#39;t exist in the project. Useful if you want consistency, but you may want to ensure this isn&#39;t checked if there could be objects in the database that were created, but didn&#39;t make it to the project.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Under the &quot;Advanced Deployment Options&quot; &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&#39;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&#39;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 &quot;Generate Script&quot; or &quot;Publish&quot;. &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=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9d6225ea-5533-4f14-806a-e97bf8bb9e0a&quot; class=&quot;wlWriterEditableSmartContent&quot; style=&quot;float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot;&gt; &lt;div style=&quot;border: #000080 1px solid; color: #000; font-family: &#39;Courier New&#39;, Courier, Monospace; font-size: 10pt&quot;&gt; &lt;div style=&quot;background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px&quot;&gt;Code Snippet&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;&quot;&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 &quot;Publish&quot; 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 &quot;Local.publish.xml&quot; (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=&quot;http://msdn.microsoft.com/en-us/library/hh550080%28v=VS.103%29.aspx&quot;&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=&quot;Local&quot; &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.    </description><link>http://schottsql.blogspot.com/2012/11/ssdt-publishing-your-project.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI3UV0nXzRtB31FoB65bSwOoz_xlCycoKvYAAfF48ox8uY9ThilqWxS1Kslrt0eswtDJWFrpebRAa3HxcPxSYEJOVWx5Lnt05dHUK-2MH9euZ_qMkmdj-ldgBcIZgttGN58pfPH-oxCgA/s72-c?imgmax=800" height="72" width="72"/><thr:total>11</thr:total></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#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK-q9OPK3T2CoEpFnyGn2vcdJaS9hcbBbH_1luDB01wPpNSULYVYt4MPpw6QOM-aLqfZaJ_8E9H3jdkMZnC4hPPwSGB47a-6L1FnqjoFthsxQW_Vs_UsudbDa8agB6AzIpsbCXYVBqmG8/s1600-h/clip_image001%25255B5%25255D.png&quot;&gt;&lt;img title=&quot;clip_image001&quot; style=&quot;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&quot; border=&quot;0&quot; alt=&quot;clip_image001&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBNWQ5gxum3gCYlD20JTUJtlS2rj0icIlQ60eSp1Tol3fQ-4KYLegM0CZ1X9eMngqZAsIZzEHB9cn1dY1Y0wzzrsLvYhg1x5dhf-y5JEpYHXZWeRFuOzLMucdFOcJ7O8SfcwywpG8igb0/?imgmax=800&quot; width=&quot;307&quot; height=&quot;123&quot;&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&#39;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&#39;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&#39;ll get an error something like this. &lt;blockquote&gt; &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2mHfqCXoYTrw2xWOWfXGRLLyI4u6940GWYXBfL4yw88P7_-wor4lCisqRZlb0726SICAR2RSBxxtkQAt3niJSO8tzbfENM2Z0HR-RX3kjZS7B_TtDZJE283A1uA2gZDeZz6kSxlotmfs/s1600-h/clip_image002%25255B4%25255D.png&quot;&gt;&lt;img title=&quot;clip_image002&quot; style=&quot;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&quot; border=&quot;0&quot; alt=&quot;clip_image002&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8Av7FcJhDodPQirjcZAC9UMlvNKGcTI75qkTDlAXOo9Is919LVv38QOM0wGFy3JSNprIKsS6HOvMlHh2lGf8-VrsJmMwkKxzhWvaS4avQYO_LFgEy3aa95Bjw23jfUXm67whHawdIvZ8/?imgmax=800&quot; width=&quot;1041&quot; height=&quot;198&quot;&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 &quot;Build&quot; tab &lt;li&gt;Enter in the numeric portion of the codes, separated by commas. Remove the &quot;SQL&quot; and any leading zeroes when entering the code.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHukr2mNMsY6FiY1Is5jkNBLBT0lSU-CeT0-CFRF5jna4mgqKQ03ls_9kyb2M9bqbupEYt6lcZHQIX3uq0T-hitzSMtJ3XYG2aZ1OLdGpTtyvZDdpCM07pjLb4X60AW0Q34VPMW0V_Sqg/s1600-h/clip_image003%25255B5%25255D.png&quot;&gt;&lt;img title=&quot;clip_image003&quot; style=&quot;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&quot; border=&quot;0&quot; alt=&quot;clip_image003&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn1HVuhYwGLq7dJYrVw3j1-JVLup2FmXK8WCfaiBBJDV_ODq55Sw2QnwBxGGhFKvgIeqkYXE4q_mXuh_E__x8mGKFCAahwTskAg_yX9YrdpsszVxI7pR4Jg3t918nZc5Xe2pxv0NLTv8o/?imgmax=800&quot; width=&quot;725&quot; height=&quot;296&quot;&gt;&lt;/a&gt;  </description><link>http://schottsql.blogspot.com/2012/11/ssdt-errors-and-warnings.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBNWQ5gxum3gCYlD20JTUJtlS2rj0icIlQ60eSp1Tol3fQ-4KYLegM0CZ1X9eMngqZAsIZzEHB9cn1dY1Y0wzzrsLvYhg1x5dhf-y5JEpYHXZWeRFuOzLMucdFOcJ7O8SfcwywpG8igb0/s72-c?imgmax=800" height="72" width="72"/><thr:total>9</thr:total></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#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><title>SSDT: Updating a Project Manually</title><description>Sometimes it&#39;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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHW62KWvl0QQoxayWLDdhH05dwSJ9yUQTAWmWdytDGm0ULMxCXCOjNl9-CO0FUfyvRissspTQiQNQo-g74-WetltDk4gMDFt848HSR8ttdTgvjGc47lQekqd5X_DbOZrdcFsxGbmwxraI/s1600-h/clip_image001%25255B3%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image001&quot; border=&quot;0&quot; height=&quot;151&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxXDwSRvyIAjm_YOhpkga8uGRC0-bAOKVdUvZadax-KuXiolfFQLI7-zWLMP-8AHt6xJbB3PjyTW3ScF3fnFuTrZy7KXkeqSHuYmNsjsO9-ePBnkrPXVAvtr-jhaiDQFGmODVkaBt6t9Y/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image001&quot; width=&quot;244&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
You have two ways to edit the file - using &quot;View Code&quot; 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&#39;ll see a new screen combining a design view with a T-SQL editor. &lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5Xyx9Nd0IvZp1RmwEKpN_CQiQXMleU_ugtCOS3DAXJqfnMmRddqy9pGgz_3dHrdCS9xAi4T8tki9Lrb6oRceXx2owA-z9rT5hB_RrbqZAYzNh420JPgjuRVZdClZJU6b03NkwJN6iUZ4/s1600-h/clip_image002%25255B5%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image002&quot; border=&quot;0&quot; height=&quot;527&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCqhI5-UL42ULfY0zDaxq6HJb9_KMRjGhxx1B98aMHEKbceIvwUcZHVs6gPpxk_psqGuPLo75nDO16ajWzonNjQ_7D8trc8hdv5heJSAKr4KGzG0iXHBLSFIOp6vkR2Cja-EQm7cilFaA/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image002&quot; width=&quot;622&quot; /&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&#39;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 &quot;GO&quot; 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&#39;s properties in the Properties window dropdown to edit its properties/description.&lt;/li&gt;
&lt;/ul&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2A4OTDEz22UTD9zlQEiPsy1DSncdvbKeYP7u2bTfrAVl6JpWZ_oRosjezUJpdYDt2SQWisdCL8N7K3TTvcHEMDQle52gnDXR7VpP0QbjzILibJTucTN4VgMNeCilZiQro2tolJj8I2no/s1600-h/clip_image003%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image003&quot; border=&quot;0&quot; height=&quot;285&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUrV-_1LUHLaqFKORrsQm7tq1L_RwfGvo9m48pAdxRrlFxWVI58VQuF7Rm0kCWXKOFfgnROYV463kT3iuOrr-75sDiEcRyIiQod2Y5lGQYBAoOToeNVP2XopSPSpG-GCEiGqMoPNzx4zs/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image003&quot; width=&quot;396&quot; /&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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXDs9mQDbpJOThmOFtyvaTDOY0SDy9VXoRI7nnLM_hFXy-ZL9R2ybvDE_aRVlxLgONvCin3d3IZHMcKocL4MQYmIjPvggj8TbpwRHU8Tfvj-pJXRPzTpdZtXXxOnl0iPKAH6wNMOmplvs/s1600-h/clip_image004%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image004&quot; border=&quot;0&quot; height=&quot;441&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjYjHzzSV_NrRR2GjDvBrLJ9-NTU0QBYy-wVVe5p-sIpYxmFjVf_SQ9010EDEKRyPb-czo6Qqk4GqBn0DA2S_lFtqXI76W4l425m2ErusOBcgrosndWFITFcLlbZSoZU2dBZw4ePj61Ts/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image004&quot; width=&quot;468&quot; /&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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfyqhA4MiXcUgXd6Z-qleDwOU2WFVHpJUOOno-oLGuUaDW8DgERoVC98_6oPGqD0TydqGo-JGPczetfsm-xY-6bk14dxYCE7-1pZ2chLIdZSfTZt07j5wrJ5n03iwhdgSIQYvNJBAH8P8/s1600-h/clip_image005%25255B5%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image005&quot; border=&quot;0&quot; height=&quot;355&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMcW5h46W34Lr5hVhzFWkEcUGnnjemvX9GbGyCRaBUm0l1Ig2XDB-VUZcVgPaWlkTnAndi0pBQIaGVaMKGNS_GfDOP08HS_sbxL0yN4L1a2oeQKWv3zYveJBVfPctbsof635RQNUgNcww/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image005&quot; width=&quot;606&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
</description><link>http://schottsql.blogspot.com/2012/11/ssdt-updating-project-manually.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxXDwSRvyIAjm_YOhpkga8uGRC0-bAOKVdUvZadax-KuXiolfFQLI7-zWLMP-8AHt6xJbB3PjyTW3ScF3fnFuTrZy7KXkeqSHuYmNsjsO9-ePBnkrPXVAvtr-jhaiDQFGmODVkaBt6t9Y/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></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#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgz8njKDbp4TuQB7rSMaBbER551-jDw5ZUQac5t0Q-dth9A9YrpP_UEALGyC7JFxpvpMNR7IGnQsNVV2sPhL9APZNWWYtSsWLrYn3vFpPieAEFvaHCyV25R7R_x_aGmSv6M87PE80heaGw/s1600-h/clip_image001%25255B5%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image001&quot; border=&quot;0&quot; height=&quot;87&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz4IU-NVXiYyWNU_13kr-1G9fuOg9P8eHkqavWHZ5aZirDVVkCprri3uZaJdW-gJgBe8DWQfMVGCLkodl1hHePjV1BE6uzGJ3K4erV3egixJ_jyKBgzE7tx1fJuUmz-JsnY-IntfxvJPs/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image001&quot; width=&quot;610&quot; /&gt;&lt;/a&gt;&lt;/blockquote&gt;
Find your script or scripts. &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzqkPyDCYWGmnzv5V8EE4qdi1LknY5A76zXAbdy1lwfgshigK-hsfSlmizrWoFz8Rr7ktuqktz5Kxmp4imdYJdWkJq9srUN3IjJ83YTtG_AfvSI22p7Bytb8nEfdvBsXIkGlANHwZ9wtg/s1600-h/clip_image002%25255B5%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image002&quot; border=&quot;0&quot; height=&quot;520&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPtT3awq2lgZTVy1q1NS4DW4sO9SlueLB08mqa0-xYI3lMio1tZOOjOABElABVqHt6zY3pQG4br7v__k1SDrtSwtle0QVHO9jYc9pNcJgSYw0eq-XwkpZforWMpbMp8JCMP2yapiwt94U/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image002&quot; width=&quot;611&quot; /&gt;&lt;/a&gt;&lt;/blockquote&gt;
Select your options for import: &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjAwyVdcfghC8CEcoabFd85btUZKF8eDbX4aEYvc_2KHlN2vro7DNuwO4ifZRyJ4X3ZBt1Bs6e06sebAsWTJ_DUSrBNpSX4jzkFaAN79ORLulbWd8oaxKjzyVvyKqnAKW3EF6BZf1kjyw/s1600-h/clip_image003%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image003&quot; border=&quot;0&quot; height=&quot;102&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqx_adwJQEmucUNkVUnE5MANom8Yn6rlMflAV3CqJGCigwzsg9BnKUFdTtT0Ux676AGcK50K_8fYc_ZNKb61wKzXK1w-uAj2pS79SECyEB9iSm7Afdoyh7VP8caRxYD7i3TqXeyJNnZA8/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image003&quot; width=&quot;696&quot; /&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&#39;ll need to manually make these changes, if applicable. In a lot of cases, the statements not understood tend to be &quot;GO&quot; 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&#39;ve also found that &quot;ALTER TABLE&quot; statements are not well understood by SSDT within the imported scripts. If you get several scripts that include these and aren&#39;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;
</description><link>http://schottsql.blogspot.com/2012/11/ssdt-updating-project-by-importing.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz4IU-NVXiYyWNU_13kr-1G9fuOg9P8eHkqavWHZ5aZirDVVkCprri3uZaJdW-gJgBe8DWQfMVGCLkodl1hHePjV1BE6uzGJ3K4erV3egixJ_jyKBgzE7tx1fJuUmz-JsnY-IntfxvJPs/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></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#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-KFtAMlAYWJtcXYZK0_OJshYDgk7PVstsy_WswICA0B67bT0Tw1mtsCy2EXeTqlvzuB9qJh_aKQKZOCHBqLnRckCEWHj-gK_sCMnQemR5EF5txZx6E-981pp9Nr1T6-m7WJrfSkonRgs/s1600-h/clip_image001%25255B3%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image001&quot; border=&quot;0&quot; height=&quot;25&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNrJ3r4lLxwci28G1ZMgnXDK4yN-KWLn5mMGsZKSZ8nW6V4DRBE7LxdnXhstkBsUQ-w-fXpi-JQDEf8_2Jmce0s0hNGuytQIdNxpakhy4hAPKuUVjpKLkPz6nSf22wZrvPM4VBHiXtkzs/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image001&quot; width=&quot;79&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The &quot;Data&quot; menu is used for the older DB Projects within VS2010. There&#39;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 &quot;SQL&quot; 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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3Aj40Bzk2m2wGOvqCPCVRuDaOBQB0Ua8dELXeBMGpMRngKUWRJb0z-0nCl3d1niFAssDpRQ4ICdh4ZoyO_wVgXcGOXFakDmyWmHhX_NtndbhS1ng-Z-pxIqdO-53ZZacgyEE2Eg9CX_s/s1600-h/clip_image002%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image002&quot; border=&quot;0&quot; height=&quot;108&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj535Afe0_x2yu6L-cbB15FibAkLAXS7H8usNrsBfey3rn28Gna-XsX0vzCv_yc6NYijq9YYpi_iF4dj8wWkmYkNhrWc-IHT7iyXeHBCVqv85wRSMXvLkmXkIO2tdESqVt5-GP4XHqYMDY/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image002&quot; width=&quot;460&quot; /&gt;&lt;/a&gt;&lt;/blockquote&gt;
To update your project from a shared database, start a &quot;New Schema Comparison&quot;. You&#39;ll see a screen something like this: &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMl4f1WD97dQbqu1g8gryfbC2RoVU1cJFTinQttNqOi653VcypsmW7kfO41oVhl0wdc0wx6uJ0Ojf1NQ7qQW0IuLg9X7zyLuOj9LjI6lscGzyfny-LamfDAh22nzgBX9TAxs2xJgmSPns/s1600-h/clip_image003%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image003&quot; border=&quot;0&quot; height=&quot;261&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4ww_yGaPkoZrTfZrr6sGBzTH3KFO49GBYTcW9NNJCnaSO31hjV3MoBJdhYiTHpuAqLuYhN5WX30KKNVygYNSgRdukWuwes9SB26T8vTeKX_-uqkHwRSVRGS6rLknKzjhkMH3Nf1rpmYg/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image003&quot; width=&quot;482&quot; /&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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpNKzxggBcf_i3n9Gq_NaU47UN3IJqhRcoHDowSMJD7A-924t5LLLUlg8_XeXxMATCvMxUL08t1r3wp4wxio3_yU46rBrmnryeI3we32kGTW-DemFmRZG6qHcFILfDxmnNdo9_P4ZAa8E/s1600-h/clip_image004%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image004&quot; border=&quot;0&quot; height=&quot;337&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqQCIxsaiBptoe8NHK3rf_-sdfq5QHQ2fKmMfyrhCY4FLqJAmsKiyJo7oSzALvqYbdwDqRVReEZKwdifVw6292-I-RdFR9J_NjsySa0l0w72iZUbTIhhdFD-pV6ACvY4XHwHmn3FKbWP4/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image004&quot; width=&quot;362&quot; /&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&#39;ve set the options to your liking, click the &quot;Compare&quot; button. &lt;br /&gt;
&lt;blockquote&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCSVfwAG-gQEe7GVoUjdZu9IsHP8HuUSuvsqqDDEUluzdAdKMKqlBQNlqwxCUfUTXelYj1YSFpcLybrEfl4FLzE7ntuvFXyi6kQVOKIStPIc9Wsq6m5XnKDT0JgPx_tMWa7JcDRxethv4/s1600-h/clip_image005%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image005&quot; border=&quot;0&quot; height=&quot;407&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgthP2WKuv5eoNlvnn5Owg4XU0x_M_YEClXtids9f1B18xnz5vP3e8sKzleGoNzWJmKgQ5J4fyifoxgK8McsLs6YcWHJ97urv_jcQvU4IGM5dBDRIZ3scxFT0_hVu9U1Uz-N2PRrRN6D4w/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image005&quot; width=&quot;474&quot; /&gt;&lt;/a&gt;&lt;/blockquote&gt;
If there are any differences, you&#39;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&#39;re satisfied with your selection, click the &quot;Update&quot; 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;
</description><link>http://schottsql.blogspot.com/2012/11/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNrJ3r4lLxwci28G1ZMgnXDK4yN-KWLn5mMGsZKSZ8nW6V4DRBE7LxdnXhstkBsUQ-w-fXpi-JQDEf8_2Jmce0s0hNGuytQIdNxpakhy4hAPKuUVjpKLkPz6nSf22wZrvPM4VBHiXtkzs/s72-c?imgmax=800" height="72" width="72"/><thr:total>4</thr:total></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#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL7wHwfV7rLERRFDx1GOQnsEZew7ygAfej3NyjGSTeXYS9cR_rI5cfQzpFO402mb3UknTgC7i2vmLlGav3_Fryp2W8ZCPu32Kskc4rW1Hbq0ykoiM6LAENsgR1C85ewhlNRmBLojZeYtA/s1600-h/clip_image001%25255B5%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image001&quot; border=&quot;0&quot; height=&quot;123&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLcaEp7XTKNTM10TPgCfPXdYEnI0i0t6egLAWJYtkgLUiiXBWRwM3vk8NBDPKSvurmPYCzRfjrSggzUl3guOoZ8lNBcuUHU0LOjh4hIYND2T1NjLgZ1_35bHK6QrLPQEHpU95BL_8KMEs/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image001&quot; width=&quot;305&quot; /&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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcgtcefBtASglg80oSmj26GunbfgBONS7gvqXOY2gOU_dq7uDfWfZGn-ctHZwpOEIFJ_WbJdnb619Umn3u8JxP0DjdyveDaHlBbkH9Dcgx11x_eR6HY6wboC60E-5JtU4w-3egaUNtGYE/s1600-h/clip_image002%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image002&quot; border=&quot;0&quot; height=&quot;249&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkq3AB38tA7DBm6E8SVo_5xPz4B6_fCupIwSVrl0MQmtB1JggHFZgGpf1hSkyunSomFDI3AO8qU9mGo941AFk2Lav3DZ35ouoquGCzGBIF6rW0cJyNAlJqu7AxLM0iB3PKRXx-ci-GDvU/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image002&quot; width=&quot;609&quot; /&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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFh2cRyR1tI1x2Nsm9wwfKJDfDfGT0S_wt24Lb_wYB804Jh9vtOHCOyYUl7OFGUpPdR0n7tY7z0OkF56YTCThCH4RSZzeDkWS-W8ka4dUMNifsRLwXAkxH2fVtgRLWI22Sq3GAxRsQp7k/s1600-h/clip_image003%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image003&quot; border=&quot;0&quot; height=&quot;181&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7DG0xsLq5wtxH_sN5Gns5y_80baxNR8uuXJtVqxl6ujYWuQEifV_ZZ4pJd6nMNJm5YGpPubUH_dDJP0ofkCksZ0at7ncf5sKVdIIupyOjkDT5R0tFzhYFdLZ12WVZO3fItvUzu0g38kA/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image003&quot; width=&quot;509&quot; /&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=&quot;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;&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: green;&quot;&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=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px; margin: 0em; width: 100%;&quot;&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 &quot;script&quot; and select the &quot;Script (Not in build)&quot; 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=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d779d1cd-8e11-4de1-9813-80c5c0768bbf&quot; style=&quot;display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;border: #000080 1px solid; color: black; font-family: &#39;Courier New&#39;, Courier, Monospace; font-size: 10pt;&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #000080; color: white; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;&quot;&gt;
Run a script called &quot;MyScript&quot;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto;&quot;&gt;
&lt;br /&gt;
&lt;ol style=&quot;background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;&quot;&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&#39;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&#39;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&#39;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;
</description><link>http://schottsql.blogspot.com/2012/11/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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLcaEp7XTKNTM10TPgCfPXdYEnI0i0t6egLAWJYtkgLUiiXBWRwM3vk8NBDPKSvurmPYCzRfjrSggzUl3guOoZ8lNBcuUHU0LOjh4hIYND2T1NjLgZ1_35bHK6QrLPQEHpU95BL_8KMEs/s72-c?imgmax=800" height="72" width="72"/><thr:total>7</thr:total></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#">SQL Server</category><category domain="http://www.blogger.com/atom/ns#">SSDT</category><category domain="http://www.blogger.com/atom/ns#">Version Control</category><title>SSDT: External Database References</title><description>If your database references other databases, you&#39;ll need a *.dacpac file for each external database referenced in your code. For example, if you reference AdventureWorksDW2008 from Adventureworks2008, you&#39;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 &quot;References&quot; folder in your project or choose the &quot;Project&quot; menu and select the option to &quot;Add Database Reference&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4h578zzZgk3efZFZ6-HepQQS3XcvX7wDE4Xn3z2nleN4ZMp8xxEuOJiwlGbGFXA3MU7RxY26fBW5AFJeH-jmu5a211h6LCDBASgSgSqT4I9NaEIxGkVP3Jr8-k3avxbjpujG-eI7GNoA/s1600-h/clip_image001%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image001&quot; border=&quot;0&quot; height=&quot;71&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfggpWUnO9GdvjtpUs43zZNvWH0Lx7l0P0RJT0rtw2Dw1qshQ6J-f73ICEEXb6m28MlkBKslZfE1JS8dO-DWXrNMnPlr3JP4utSBROzT54buzBj_PUK0kDE2usrCRIL0gJYSc9bAK99pY/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image001&quot; width=&quot;339&quot; /&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&#39;t change, clear out the &quot;Database Variable&quot; column. It isn&#39;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&#39;ll need to replace this reference in your code with the variable from this column. &lt;/li&gt;
&lt;li&gt;If you&#39;re referencing a database on a linked server, this would probably be better served with a static database name and a &quot;Server Variable&quot;. 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&#39;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=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj4zpg_yEpq7czAR068S1ENNSwBv8ElYiS-NumhQvGc3a0iCSe4FSExIaEwP5QR2UI2yH1dvFEVrnUN55RylP94b49jh0laTpeXQSDoMbeBQIsiLilcvPQzOfKLqcUUYA6gcJwbZQI-5o/s1600-h/clip_image002%25255B5%25255D.png&quot;&gt;&lt;img alt=&quot;clip_image002&quot; border=&quot;0&quot; height=&quot;482&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhthGmNfHO-iCK8XcEyQZ5t8xdQQn0NlftOBzSadXi54HQXU-PyR98zmWu4-xm8gbDwChbwu_uLOYLRB_8-_Y470wHOurWjnqXSPPz0XYADWyuYilEV_JJgas4Fk0Jtwdi65zrK-69HroU/?imgmax=800&quot; style=&quot;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;&quot; title=&quot;clip_image002&quot; width=&quot;695&quot; /&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 &quot;90&quot; 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;
</description><link>http://schottsql.blogspot.com/2012/10/ssdt-external-database-references.html</link><author>noreply@blogger.com (Peter Schott)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfggpWUnO9GdvjtpUs43zZNvWH0Lx7l0P0RJT0rtw2Dw1qshQ6J-f73ICEEXb6m28MlkBKslZfE1JS8dO-DWXrNMnPlr3JP4utSBROzT54buzBj_PUK0kDE2usrCRIL0gJYSc9bAK99pY/s72-c?imgmax=800" height="72" width="72"/><thr:total>43</thr:total></item></channel></rss>