<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0' gd:etag='W/&quot;DkYBQ38yfyp7ImA9WhJVFE8.&quot;'><id>tag:blogger.com,1999:blog-12181313</id><updated>2012-08-31T07:42:32.197-07:00</updated><category term='SQL2008'/><category term='Change Tracking'/><category term='Timestamp'/><category term='Rowversion'/><title>Useful SQL Server scripts</title><subtitle type='html'>This Blog is about MSSQL server 2000/2005 and 2008</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default?redirect=false&amp;v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>283</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry gd:etag='W/&quot;DkYBQ3w9fSp7ImA9WhJVFE8.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-149936940249982216</id><published>2012-08-31T07:42:00.003-07:00</published><updated>2012-08-31T07:42:32.265-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-08-31T07:42:32.265-07:00</app:edited><title>parent child relation hierachy script</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;with cte as &lt;br /&gt;(&lt;br /&gt;select 1 as lvl, SpaceShuttleID , ParentSpaceShuttleID from SpaceShuttle where SpaceShuttleID = 200&lt;br /&gt;union all&lt;br /&gt;select
 cte.lvl + 1, b.SpaceShuttleID , b.ParentSpaceShuttleID&amp;nbsp; from 
SpaceShuttle b join cte on cte.SpaceShuttleID = b.ParentSpaceShuttleID&lt;br /&gt;)&lt;br /&gt;select * from cte order by lvl;&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-149936940249982216?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/149936940249982216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=149936940249982216' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/149936940249982216?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/149936940249982216?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/08/parent-child-relation-hierachy-script.html' title='parent child relation hierachy script'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;Ck4BR30yeyp7ImA9WhJWEk8.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-7733830190175783177</id><published>2012-08-17T09:29:00.002-07:00</published><updated>2012-08-17T09:29:16.393-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-08-17T09:29:16.393-07:00</app:edited><title>modify sysjobs trigger to send alert</title><content type='html'>USE [msdb]&lt;br /&gt;GO&lt;br /&gt;/****** Object:&amp;nbsp; Trigger [dbo].[trig_sysjobs_insert_update]&amp;nbsp;&amp;nbsp;&amp;nbsp; Script Date: 08/17/2012 08:56:33 ******/&lt;br /&gt;SET ANSI_NULLS ON&lt;br /&gt;GO&lt;br /&gt;SET QUOTED_IDENTIFIER OFF&lt;br /&gt;GO&lt;br /&gt;ALTER TRIGGER [dbo].[trig_sysjobs_insert_update]&lt;br /&gt;ON [dbo].[sysjobs]&lt;br /&gt;FOR INSERT, UPDATE&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt;&amp;nbsp; SET NOCOUNT ON&lt;br /&gt;&amp;nbsp; -- Disallow the insert or update if the originating_server_id isn't in sysoriginatingservers_view.&amp;nbsp; &lt;br /&gt;&amp;nbsp; IF (EXISTS (SELECT *&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; FROM inserted&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE inserted.originating_server_id NOT IN &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; (SELECT v.originating_server_id &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; FROM sysoriginatingservers_view AS v)))&lt;br /&gt;&amp;nbsp; BEGIN&lt;br /&gt;&amp;nbsp;&amp;nbsp; RAISERROR(14379, -1, -1, 'dbo.sysjobs')&lt;br /&gt;&amp;nbsp;&amp;nbsp; ROLLBACK TRANSACTION&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RETURN&lt;br /&gt;&amp;nbsp; END&lt;br /&gt;&amp;nbsp; else&lt;br /&gt;&amp;nbsp; begin&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Declare @Body1 nvarchar(max)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select @Body1 = 'SQL Server Job Name: ' + name + ' modified on '+convert(varchar, date_modified,9) from inserted&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EXEC msdb.dbo.sp_send_dbmail&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @profile_name = 'default',&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @recipients = 'palexander@csod.com',&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @body = @Body1,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @subject = 'SQL Server Job Modification Alert'&lt;br /&gt;&lt;br /&gt;&amp;nbsp; end&lt;br /&gt;END&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-7733830190175783177?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/7733830190175783177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=7733830190175783177' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/7733830190175783177?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/7733830190175783177?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/08/modify-sysjobs-trigger-to-send-alert.html' title='modify sysjobs trigger to send alert'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DU4CRXw-fip7ImA9WhJWEU4.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-4637151310096287335</id><published>2012-08-16T09:50:00.001-07:00</published><updated>2012-08-16T10:26:04.256-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-08-16T10:26:04.256-07:00</app:edited><title>SQL job queries</title><content type='html'>--JOB INFO&lt;br /&gt;
select * &lt;br /&gt;
from sysjobs a&lt;br /&gt;
inner join sysjobschedules b on a.job_id = b.job_id&lt;br /&gt;
inner join sysschedules c on b.schedule_id = c.schedule_id&lt;br /&gt;
--where a.name like '%SoapFeedJobs%'&lt;br /&gt;
where a.name like '%CES Daily Maintenance - VLINE%'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--JOB HISTORY&lt;br /&gt;
select *&lt;br /&gt;
from msdb.dbo.sysjobs j &lt;br /&gt;
LEFT OUTER JOIN msdb.dbo.syscategories c ON j.category_id = c.category_id &lt;br /&gt;
LEFT OUTER JOIN msdb.dbo.sysjobhistory h ON j.job_id = h.job_id AND h.step_id = 0 --AND x.last_run_date = h.run_date AND x.last_run_time = h.run_time&lt;br /&gt;
--where j.name like '%SoapFeedJobs-ces_Akamai%'&lt;br /&gt;
where j.name like '%CES Daily Maintenance - VLINE%'&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;--JOB HISTORY with outcome result&lt;br /&gt;
select &lt;br /&gt;Case isnull(h.run_status,'') WHEN '' THEN 'Unknown' WHEN 0 THEN 'Fail'WHEN 1 THEN 'Success' WHEN 2 THEN 'Retry' WHEN 3 THEN 'Cancel' WHEN 4 THEN 'In progress' End AS LastRunOutcome,&lt;br /&gt;CASE WHEN h.run_duration &amp;gt; 0 THEN (h.run_duration / 1000000) * (3600 * 24) + (h.run_duration / 10000 % 100) * 3600 + (h.run_duration / 100 % 100) * 60 + (h.run_duration % 100) Else NULL End AS LastRunDuration ,&lt;br /&gt;*&lt;br /&gt;from msdb.dbo.sysjobs j &lt;br /&gt;LEFT OUTER JOIN msdb.dbo.syscategories c ON j.category_id = c.category_id &lt;br /&gt;LEFT OUTER JOIN msdb.dbo.sysjobhistory h ON j.job_id = h.job_id AND h.step_id = 0 --AND x.last_run_date = h.run_date AND x.last_run_time = h.run_time&lt;br /&gt;--where j.name like '%SoapFeedJobs-ces_Akamai%'&lt;br /&gt;where j.name like '%CES Daily Maintenance - VLINE%' &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-4637151310096287335?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/4637151310096287335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=4637151310096287335' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/4637151310096287335?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/4637151310096287335?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/08/sql-job-queries.html' title='SQL job queries'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0cMQH44cCp7ImA9WhJWEEs.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-6849211742584195855</id><published>2012-08-15T13:04:00.001-07:00</published><updated>2012-08-15T13:04:41.038-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-08-15T13:04:41.038-07:00</app:edited><title>lists all the default constraints and the default values for the user tables in the database</title><content type='html'>&lt;pre class="lang-sql prettyprint"&gt;&lt;code&gt;&lt;span class="kwd"&gt;SELECT&lt;/span&gt;&lt;span class="pln"&gt; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; b&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;name &lt;/span&gt;&lt;span class="kwd"&gt;AS&lt;/span&gt;&lt;span class="pln"&gt; TABLE_NAME&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; d&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;name &lt;/span&gt;&lt;span class="kwd"&gt;AS&lt;/span&gt;&lt;span class="pln"&gt; COLUMN_NAME&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;name &lt;/span&gt;&lt;span class="kwd"&gt;AS&lt;/span&gt;&lt;span class="pln"&gt; CONSTRAINT_NAME&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;text &lt;/span&gt;&lt;span class="kwd"&gt;AS&lt;/span&gt;&lt;span class="pln"&gt; DEFAULT_VALUE&lt;/span&gt;&lt;span class="kwd"&gt;FROM&lt;/span&gt;&lt;span class="pln"&gt; sys&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;sysobjects a &lt;/span&gt;&lt;span class="kwd"&gt;INNER&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;JOIN&lt;/span&gt;&lt;span class="pln"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;SELECT&lt;/span&gt;&lt;span class="pln"&gt; name&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; id
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="kwd"&gt;FROM&lt;/span&gt;&lt;span class="pln"&gt; sys&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;sysobjects 
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="kwd"&gt;WHERE&lt;/span&gt;&lt;span class="pln"&gt; xtype &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="str"&gt;'U'&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt; b &lt;/span&gt;&lt;span class="kwd"&gt;on&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;a&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;parent_obj &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; b&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;id&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;INNER&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;JOIN&lt;/span&gt;&lt;span class="pln"&gt; sys&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;syscomments c &lt;/span&gt;&lt;span class="kwd"&gt;ON&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;a&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;id &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; c&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;id&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="kwd"&gt;INNER&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;JOIN&lt;/span&gt;&lt;span class="pln"&gt; sys&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;syscolumns d &lt;/span&gt;&lt;span class="kwd"&gt;ON&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;d&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;cdefault &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; a&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;id&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&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;&lt;/span&gt;&lt;span class="kwd"&gt;WHERE&lt;/span&gt;&lt;span class="pln"&gt; a&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;xtype &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="str"&gt;'D'&lt;/span&gt;&lt;span class="pln"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp;&lt;/span&gt;&lt;span class="kwd"&gt;ORDER&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;BY&lt;/span&gt;&lt;span class="pln"&gt; b&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;name&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; a&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;name&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-6849211742584195855?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/6849211742584195855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=6849211742584195855' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/6849211742584195855?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/6849211742584195855?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/08/lists-all-default-constraints-and.html' title='lists all the default constraints and the default values for the user tables in the database'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;A04DQXY_eyp7ImA9WhJWEEg.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-3560694108870176828</id><published>2012-08-15T12:46:00.001-07:00</published><updated>2012-08-15T12:46:10.843-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-08-15T12:46:10.843-07:00</app:edited><title>function to get time for next job</title><content type='html'>use msdb&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;select dbo.fn_next_job_time(15, null, null)&lt;br /&gt;select dbo.fn_next_job_time(7, null, null)&lt;br /&gt;select dbo.fn_next_job_time(7, 'CES Weekly Maintenance -','Weekend Sat')&lt;br /&gt;select dbo.fn_next_job_time(7, 'CES Weekly Maintenance -',null)&lt;br /&gt;select dbo.fn_next_job_time(4, 'CES Weekly Maintenance -',null)&lt;br /&gt;*/&lt;br /&gt;CREATE FUNCTION fn_next_job_time&lt;br /&gt;(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @interval int = 10,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @jobname nvarchar(100) = null ,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @schedulename nvarchar(100) = null&lt;br /&gt;)&lt;br /&gt;RETURNS int&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @jobname = @jobname + '%'&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @schedulename = @schedulename + '%'&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare @curr_hr int, @curr_min int, @curr_sec int, @next_hr int, @next_min int, @next_sec int&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare @nexttime int &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --set @nexttime = 10004&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --set @nexttime = 206&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --set @nexttime = 5506&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --set @nexttime = 230847&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --set @nexttime = 145712&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --set @nexttime = 41942&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --set @nexttime = 225847&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --set @nexttime = 235847&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select top 1 @nexttime = c.active_start_time&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --a.schedule_id, b.name, c.active_start_time,c.name, *&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sysjobschedules a &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inner join sysjobs b on a.job_id = b.job_id&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inner join sysschedules c on a.schedule_id = c.schedule_id&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (b.name like @jobname or @jobname is null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; and &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ( c.name like @schedulename or @schedulename is null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by c.active_start_time desc&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select @curr_hr = right(convert(nvarchar(10), @nexttime/10000),2) , @curr_min = right(convert(nvarchar(10),&amp;nbsp; @nexttime/100),2),&amp;nbsp; @curr_sec = right(convert(nvarchar(10), @nexttime),2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @next_sec = @curr_sec&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @next_min = (@curr_min + @interval)%60&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @next_hr =&amp;nbsp; @curr_hr + (@curr_min + @interval)/ 60&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @next_hr = case when @next_hr &amp;gt;= 24 then 0 else @next_hr&amp;nbsp; end&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --select @nexttime, @curr_hr , @curr_min , @curr_sec&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --select @nexttime, @next_hr , @next_min , @next_sec&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select @nexttime = convert(int, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (case when @next_hr&amp;nbsp; &amp;lt; 10 then '0'+CONVERT(nvarchar(10),@next_hr ) else convert(nvarchar(10),@next_hr ) end) +&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (case when @next_min&amp;nbsp; &amp;lt; 10 then '0'+CONVERT(nvarchar(10),@next_min ) else convert(nvarchar(10),@next_min ) end) +&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (case when @next_sec &amp;lt; 10 then '0'+CONVERT(nvarchar(10),@next_sec) else convert(nvarchar(10),@next_sec) end) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RETURN @nexttime&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-3560694108870176828?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/3560694108870176828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=3560694108870176828' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/3560694108870176828?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/3560694108870176828?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/08/function-to-get-time-for-next-job.html' title='function to get time for next job'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D0INQnoyfyp7ImA9WhJRFk8.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-5723919214760906322</id><published>2012-07-18T08:33:00.001-07:00</published><updated>2012-07-18T08:33:13.497-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-07-18T08:33:13.497-07:00</app:edited><title>list spaces used by all DBs in a server : sp_dbspaceall</title><content type='html'>use master&lt;br /&gt;go&lt;br /&gt;IF&amp;nbsp; EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_dbspaceall]') AND type in (N'P', N'PC'))&lt;br /&gt;DROP PROCEDURE [dbo].[sp_dbspaceall]&lt;br /&gt;GO&lt;br /&gt;/*&lt;br /&gt;exec sp_dbspaceall&lt;br /&gt;*/&lt;br /&gt;create procedure sp_dbspaceall&lt;br /&gt;as&lt;br /&gt;begin&lt;br /&gt;&lt;br /&gt;Declare @FileSpace table (&lt;br /&gt;[database_id] int,&lt;br /&gt;[db_name] nvarchar(100),&lt;br /&gt;[file_id] int,&lt;br /&gt;[file_name] nvarchar(100),&lt;br /&gt;[space_used] bigint&lt;br /&gt;)&lt;br /&gt;INSERT INTO @FileSpace&amp;nbsp; EXEC sp_MSforeachdb 'USE [?] SELECT db_id(''?''),''?'' as DBname,fileid, name ,FILEPROPERTY(name, ''SpaceUsed'')&amp;nbsp; as spaceused from sys.sysfiles';&lt;br /&gt;&lt;br /&gt;With SpaceInfo (DBName, FileName, FileType,FilePath,CurrentSizeMB,SpaceUsedMB)&lt;br /&gt;as&lt;br /&gt;(&lt;br /&gt;&lt;br /&gt;SELECT&lt;br /&gt;DB_NAME(df.[database_id]) as [DBName],&lt;br /&gt;df.[name] as [FileName] ,&lt;br /&gt;df.type_desc as [FileType],&lt;br /&gt;df.physical_name as [FilePath],&lt;br /&gt;(df.[size]*8.0)/1024.0 as [CurrentSizeMB],&lt;br /&gt;(fs.[space_used]*8.0)/1024.0 as [SpaceUsedMB]&lt;br /&gt;FROM&amp;nbsp; &lt;br /&gt;SYS.MASTER_FILES AS df&lt;br /&gt;INNER JOIN @FileSpace as fs on (df.[database_id]= FS.[database_id] and df.[file_id]=fs.[file_id])&lt;br /&gt;)&lt;br /&gt;SELECT&lt;br /&gt;SI.DBName,&lt;br /&gt;convert(dec(17,2),SUM(SI.CurrentSizeMB)) as [DatabaseSizeMB],&lt;br /&gt;convert(dec(14,2),(1-(SUM(SI.SpaceUsedMB)/SUM(SI.CurrentSizeMB)))*100 )as [%age Free],&lt;br /&gt;convert(dec(17,2),D.DataFileSizeMB) as&amp;nbsp; DataFileSizeMB,&lt;br /&gt;convert(dec(14,2) ,(1-(D.DataFileSpaceUsedMB/D.DataFileSizeMB))*100) as [%age Free],&lt;br /&gt;convert(dec(17,2),L.LogFileSizeMB) as LogFileSizeMB,&lt;br /&gt;convert(dec(14,2),(1-(L.LogFileSpaceUsedMB/L.LogFileSizeMB))*100)&amp;nbsp; as [%age Free]&lt;br /&gt;FROM&lt;br /&gt;SpaceInfo SI&lt;br /&gt;CROSS APPLY (SELECT&amp;nbsp; sum(CurrentSizeMB) as [DataFileSizeMB], SUM(SpaceUsedMB) as [DataFileSpaceUsedMB] FROM SpaceInfo&lt;br /&gt;WHERE filetype='ROWS' and DBName=SI.DBName group by DBName)&amp;nbsp; as D&lt;br /&gt;CROSS APPLY (SELECT&amp;nbsp; sum(CurrentSizeMB) as [LogFileSizeMB], SUM(SpaceUsedMB) as [LogFileSpaceUsedMB] FROM SpaceInfo&lt;br /&gt;WHERE filetype ='LOG' and DBName=SI.DBName group by DBName)&amp;nbsp; as L&lt;br /&gt;GROUP BY&lt;br /&gt;SI.DBName, D.DataFileSizeMB,D.DataFileSpaceUsedMB,L.LogFileSizeMB,L.LogFileSpaceUsedMB&lt;br /&gt;Order by D.DataFileSizeMB desc&lt;br /&gt;end&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-5723919214760906322?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/5723919214760906322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=5723919214760906322' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/5723919214760906322?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/5723919214760906322?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/07/list-spaces-used-by-all-dbs-in-server.html' title='list spaces used by all DBs in a server : sp_dbspaceall'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;A04NSH87fyp7ImA9WhJRFkw.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-3258797944950113319</id><published>2012-07-18T06:59:00.001-07:00</published><updated>2012-07-18T06:59:59.107-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-07-18T06:59:59.107-07:00</app:edited><title>SQL Query Stress Tool</title><content type='html'>&lt;a href="http://www.mssqltips.com/sqlservertip/2730/sql-query-stress-tool/?utm_source=dailynewsletter&amp;amp;utm_medium=email&amp;amp;utm_content=headline&amp;amp;utm_campaign=2012717"&gt;http://www.mssqltips.com/sqlservertip/2730/sql-query-stress-tool/?utm_source=dailynewsletter&amp;amp;utm_medium=email&amp;amp;utm_content=headline&amp;amp;utm_campaign=2012717&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-3258797944950113319?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/3258797944950113319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=3258797944950113319' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/3258797944950113319?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/3258797944950113319?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/07/sql-query-stress-tool.html' title='SQL Query Stress Tool'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;Ak4BSH4-eSp7ImA9WhJRFEg.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-6065257051778911861</id><published>2012-07-16T10:15:00.005-07:00</published><updated>2012-07-16T10:15:59.051-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-07-16T10:15:59.051-07:00</app:edited><title>Top SQL Server Tools SQL compliance manager  SQL diagnostic manager  SQL Monitor  SQL Sentry Performance Advisor for SQL Server  SQL safe backup         SSAS Interview Questions on Measures, Actions, and Storage</title><content type='html'>&lt;a href="http://www.mssqltips.com/sqlservertip/2637/ssas-interview-questions-part-i-questions-on-basic-concepts-data-sources-and-data-source-views/"&gt;http://www.mssqltips.com/sqlservertip/2637/ssas-interview-questions-part-i-questions-on-basic-concepts-data-sources-and-data-source-views/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.mssqltips.com/sqlservertip/2662/sql-server-analysis-services-interview-questions-part-ii--dimensions/"&gt;http://www.mssqltips.com/sqlservertip/2662/sql-server-analysis-services-interview-questions-part-ii--dimensions/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.mssqltips.com/sqlservertip/2683/sql-server-analysis-services-interview-questions-on-dimensions-hierarchies-and-properties/"&gt;http://www.mssqltips.com/sqlservertip/2683/sql-server-analysis-services-interview-questions-on-dimensions-hierarchies-and-properties/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.mssqltips.com/sqlservertip/2614/ssas-interview-questions-on-measures-actions-and-storage/?utm_source=dailynewsletter&amp;amp;utm_medium=email&amp;amp;utm_content=headline&amp;amp;utm_campaign=2012715"&gt;http://www.mssqltips.com/sqlservertip/2614/ssas-interview-questions-on-measures-actions-and-storage/?utm_source=dailynewsletter&amp;amp;utm_medium=email&amp;amp;utm_content=headline&amp;amp;utm_campaign=2012715&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-6065257051778911861?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/6065257051778911861/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=6065257051778911861' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/6065257051778911861?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/6065257051778911861?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/07/top-sql-server-tools-sql-compliance.html' title='Top SQL Server Tools SQL compliance manager  SQL diagnostic manager  SQL Monitor  SQL Sentry Performance Advisor for SQL Server  SQL safe backup         SSAS Interview Questions on Measures, Actions, and Storage'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;Dk8BRHk_eSp7ImA9WhJREkw.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-8230418806595874645</id><published>2012-07-13T14:27:00.001-07:00</published><updated>2012-07-13T14:27:35.741-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-07-13T14:27:35.741-07:00</app:edited><title>Importing SQL Server Data Using SSIS - Which Option is Fastest</title><content type='html'>&lt;a href="http://www.mssqltips.com/sqlservertip/2684/importing-sql-server-data-using-ssis--which-option-is-fastest/"&gt;http://www.mssqltips.com/sqlservertip/2684/importing-sql-server-data-using-ssis--which-option-is-fastest/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-8230418806595874645?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/8230418806595874645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=8230418806595874645' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/8230418806595874645?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/8230418806595874645?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/07/importing-sql-server-data-using-ssis.html' title='Importing SQL Server Data Using SSIS - Which Option is Fastest'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CE4DRXY4eyp7ImA9WhJREE8.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-4058387030115702612</id><published>2012-07-11T09:09:00.002-07:00</published><updated>2012-07-11T09:09:34.833-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-07-11T09:09:34.833-07:00</app:edited><title>Preventing from Dropping database</title><content type='html'>CREATE TRIGGER [ddl_trig_Prevent_Drop_Database] &lt;br /&gt;ON ALL SERVER &lt;br /&gt;FOR DROP_DATABASE &lt;br /&gt;AS&lt;br /&gt;&lt;br /&gt;DECLARE @db VARCHAR(800) &lt;br /&gt;SET @db = (SELECT 'Database Dropped Attempted by ' + CONVERT(nvarchar(100), ORIGINAL_LOGIN()) + &lt;br /&gt;' executing command: '+ EVENTDATA().value('(/EVENT_INSTANCE/TSQLCommand/CommandText)[1]','VARCHAR(229)')) + '&lt;br /&gt;&lt;br /&gt;To temporarily allow dropping action: &lt;br /&gt;DISABLE TRIGGER ddl_trig_Prevent_Drop_Database ON ALL SERVER;&lt;br /&gt;&lt;br /&gt;!!!!!!MAKE SURE TO RE-ENABLE THE TRIGGER CHECK AS SOON AS YOU ARE DONE!!!!!! &lt;br /&gt;ENABLE TRIGGER ddl_trig_Prevent_Drop_Database ON ALL SERVER; &lt;br /&gt;' &lt;br /&gt;RAISERROR(@db, 16, 1)WITH LOG&lt;br /&gt;&lt;br /&gt;ROLLBACK &lt;br /&gt;&lt;br /&gt;GO&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-4058387030115702612?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/4058387030115702612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=4058387030115702612' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/4058387030115702612?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/4058387030115702612?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/07/preventing-from-dropping-database.html' title='Preventing from Dropping database'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DUMBQXo7fip7ImA9WhJSE04.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-3902539833167813154</id><published>2012-07-03T10:44:00.001-07:00</published><updated>2012-07-03T10:44:10.406-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-07-03T10:44:10.406-07:00</app:edited><title>Disable Enable indexes</title><content type='html'>select&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.objects.name,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.indexes.name,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'alter index '+ sys.indexes.name +' on '+sys.objects.name+' rebuild',&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'alter index '+ sys.indexes.name +' on '+sys.objects.name+' disable'&lt;br /&gt;from sys.indexes&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inner join sys.objects on sys.objects.object_id = sys.indexes.object_id&lt;br /&gt;where sys.indexes.is_disabled = 1&lt;br /&gt;order by&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.objects.name,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.indexes.name&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-3902539833167813154?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/3902539833167813154/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=3902539833167813154' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/3902539833167813154?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/3902539833167813154?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/07/disable-enable-indexes.html' title='Disable Enable indexes'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DEMGRX09eyp7ImA9WhVaFE4.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-5572557308813505893</id><published>2012-06-11T10:40:00.000-07:00</published><updated>2012-06-11T10:40:24.363-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-06-11T10:40:24.363-07:00</app:edited><title>Ordering and Ranking a data set</title><content type='html'>useful&amp;nbsp;technique&amp;nbsp;to pre-order data set&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
select&lt;br /&gt;
DENSE_RANK() over (order by name_first),&lt;br /&gt;
RANK() over (order by name_first),&lt;br /&gt;
ROW_NUMBER() over (order by name_first),&lt;br /&gt;
ROW_NUMBER() over (order by name_last),&lt;br /&gt;
*&lt;br /&gt;
from users&lt;br /&gt;
order by name_first, name_last&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-5572557308813505893?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/5572557308813505893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=5572557308813505893' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/5572557308813505893?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/5572557308813505893?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/06/ordering-and-ranking-data-set.html' title='Ordering and Ranking a data set'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0QERHgzeip7ImA9WhVVEEs.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-2514707614741146224</id><published>2012-05-03T09:06:00.001-07:00</published><updated>2012-05-03T09:08:25.682-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-05-03T09:08:25.682-07:00</app:edited><title>Database Encryption with DB Certificates</title><content type='html'>&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
&lt;b&gt;&lt;u&gt;SQL Servers Database
Encryption on Swim lanes&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
This document is create on May 2&lt;sup&gt;nd&lt;/sup&gt;, 2012 and is
valid for Swim Lanes. Certificates are installed on LD4PRDCLT101 and this
version of the certificate and key should be used across all swim lanes if
needed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Create a new Master Key&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;USE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;master&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;MASTER&lt;/span&gt;
&lt;span style="color: blue;"&gt;KEY&lt;/span&gt; &lt;span style="color: blue;"&gt;ENCRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Password'&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;Go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;--To Drop the masterkey&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;--DROP MASTER KEY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Create a new Certificate per Database that need to be
encrypted&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;--database encryption key&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormalCxSpMiddle" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt; DatabaseName1_Cert &lt;span style="color: blue;"&gt;WITH&lt;/span&gt; &lt;span style="color: blue;"&gt;SUBJECT&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'DatabaseName1 Certificate'&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormalCxSpMiddle" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;Go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormalCxSpMiddle" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt; DatabaseName2_Cert &lt;span style="color: blue;"&gt;WITH&lt;/span&gt; &lt;span style="color: blue;"&gt;SUBJECT&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'DatabaseName2 Certificate'&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormalCxSpMiddle" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;Go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormalCxSpMiddle" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt; DatabaseName3_Cert &lt;span style="color: blue;"&gt;WITH&lt;/span&gt; &lt;span style="color: blue;"&gt;SUBJECT&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'DatabaseName3 Certificate'&lt;/span&gt;&lt;span style="color: green;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormalCxSpMiddle" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;Go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;--To Drop the certificate&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .5in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;-- DROP
CERTIFICATE &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;DatabaseName1_Cert&lt;span style="color: blue;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Backup Master Key and certificates and use for restoring
databases on a different server&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;Use&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;master&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;Backup&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;master&lt;/span&gt;
&lt;span style="color: blue;"&gt;key&lt;/span&gt; &lt;span style="color: blue;"&gt;to&lt;/span&gt; &lt;span style="color: blue;"&gt;file&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'C:\MasterKey.key'&lt;/span&gt; &lt;span style="color: blue;"&gt;encryption&lt;/span&gt;
&lt;span style="color: blue;"&gt;by&lt;/span&gt; &lt;span style="color: blue;"&gt;password&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Password'&lt;/span&gt; ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 1in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;BACKUP&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt;
DatabaseName1_Cert &lt;span style="color: blue;"&gt;TO&lt;/span&gt; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt;
&lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'c:\DatabaseName1_Cert_file.cert'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;WITH&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;PRIVATE&lt;/span&gt;
&lt;span style="color: blue;"&gt;KEY &lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'c:\DatabaseName1_Cert_key.cert'&lt;/span&gt; &lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;ENCRYPTION&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt;
&lt;span style="color: blue;"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Password'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;BACKUP&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt;
DatabaseName2_Cert &lt;span style="color: blue;"&gt;TO&lt;/span&gt; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt;
&lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'c:\DatabaseName2_Cert_file.cert'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;WITH&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;PRIVATE&lt;/span&gt;
&lt;span style="color: blue;"&gt;KEY &lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'c:\DatabaseName2_Cert_key.cert'&lt;/span&gt; &lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;ENCRYPTION&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt;
&lt;span style="color: blue;"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Password'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;BACKUP&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt;
DatabaseName3_Cert &lt;span style="color: blue;"&gt;TO&lt;/span&gt; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt;
&lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'c:\DatabaseName3_Cert_file.cert'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;WITH&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;PRIVATE&lt;/span&gt;
&lt;span style="color: blue;"&gt;KEY &lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'c:\DatabaseName3_Cert_key.cert'&lt;/span&gt; &lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;ENCRYPTION&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt;
&lt;span style="color: blue;"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Password'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;);&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Create certificates from a backup certificate on another
server, (note:&amp;nbsp; the master key should be
created before this can be done)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt;
DatabaseName1_Cert &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;FROM&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt;
&lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'C:\DatabaseName1_Cert_file.cert'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;WITH&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;PRIVATE&lt;/span&gt;
&lt;span style="color: blue;"&gt;KEY &lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;FILE&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'C:\DatabaseName1_Cert_key.cert'&lt;/span&gt; &lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;DECRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Password'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt;
DatabaseName2_Cert &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;FROM&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt;
&lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'C:\DatabaseName2_Cert_file.cert'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;WITH&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;PRIVATE&lt;/span&gt;
&lt;span style="color: blue;"&gt;KEY &lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;FILE&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'C:\DatabaseName2_Cert_key.cert'&lt;/span&gt; &lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;DECRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Password'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt;
DatabaseName3_Cert &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;FROM&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt;
&lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'C:\DatabaseName3_Cert_file.cert'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;WITH&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;PRIVATE&lt;/span&gt;
&lt;span style="color: blue;"&gt;KEY &lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;FILE&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'C:\DatabaseName3_Cert_key.cert'&lt;/span&gt; &lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;DECRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Password'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style="font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin;"&gt;&lt;br clear="all" style="mso-special-character: line-break; page-break-before: always;" /&gt;
&lt;/span&gt;

&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Encrypt a Database&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;USE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; [DatabaseName1]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
&lt;span style="color: blue;"&gt;ENCRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;WITH&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;ALGORITHM&lt;/span&gt;
&lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;AES_256&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;ENCRYPTION&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt;
&lt;span style="color: blue;"&gt;SERVER&lt;/span&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt;
DatabaseName1_Cert&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;ALTER&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
[DatabaseName1]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;SET&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;ENCRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .5in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;USE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; [DatabaseName2]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
&lt;span style="color: blue;"&gt;ENCRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;WITH&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;ALGORITHM&lt;/span&gt;
&lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;AES_256&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;ENCRYPTION&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt;
&lt;span style="color: blue;"&gt;SERVER&lt;/span&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt;
DatabaseName2_Cert&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;ALTER&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
[DatabaseName2]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;SET&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;ENCRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .5in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;USE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; [DatabaseName3]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
&lt;span style="color: blue;"&gt;ENCRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;WITH&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;ALGORITHM&lt;/span&gt;
&lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;AES_256&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;ENCRYPTION&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt;
&lt;span style="color: blue;"&gt;SERVER&lt;/span&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt;
DatabaseName3_Cert&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;ALTER&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
[DatabaseName3]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;SET&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;ENCRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .5in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Restore the Databases on a separate server, the key and
certificates should be already created and restored. If the certificates are
not created properly the restore will fail.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;RESTORE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
[DatabaseName1_retored] &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;FROM&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;&amp;nbsp;
&lt;span style="color: blue;"&gt;DISK&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;N'c:\DatabaseName1.bak'&lt;/span&gt; &lt;span style="color: blue;"&gt;WITH&lt;/span&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;MOVE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: red;"&gt;N'Data'&lt;/span&gt;
&lt;span style="color: blue;"&gt;TO&lt;/span&gt; &lt;span style="color: red;"&gt;N'E:\DATA_Release\DatabaseName1.mdf'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;MOVE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: red;"&gt;N'Log'&lt;/span&gt;
&lt;span style="color: blue;"&gt;TO&lt;/span&gt; &lt;span style="color: red;"&gt;N'E:\LOG_Release\DatabaseName1.LDF'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;NOUNLOAD&lt;/span&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;,&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;&amp;nbsp; &lt;span style="color: magenta;"&gt;REPLACE&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;span style="color: green;"&gt;STATS&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; 10&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;RESTORE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
[DatabaseName2_retored] &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;FROM&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;&amp;nbsp;
&lt;span style="color: blue;"&gt;DISK&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;N'c:\DatabaseName2.bak'&lt;/span&gt; &lt;span style="color: blue;"&gt;WITH&lt;/span&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;MOVE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: red;"&gt;N'Data'&lt;/span&gt;
&lt;span style="color: blue;"&gt;TO&lt;/span&gt; &lt;span style="color: red;"&gt;N'E:\DATA_Release\DatabaseName2.mdf'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;MOVE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: red;"&gt;N'Log'&lt;/span&gt;
&lt;span style="color: blue;"&gt;TO&lt;/span&gt; &lt;span style="color: red;"&gt;N'E:\LOG_Release\DatabaseName2.LDF'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;NOUNLOAD&lt;/span&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;,&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;&amp;nbsp; &lt;span style="color: magenta;"&gt;REPLACE&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;span style="color: green;"&gt;STATS&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; 10&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;RESTORE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
[DatabaseName3_retored] &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;FROM&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;&amp;nbsp;
&lt;span style="color: blue;"&gt;DISK&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;N'c:\DatabaseName3.bak'&lt;/span&gt; &lt;span style="color: blue;"&gt;WITH&lt;/span&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;FILE&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;MOVE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: red;"&gt;N'Data'&lt;/span&gt;
&lt;span style="color: blue;"&gt;TO&lt;/span&gt; &lt;span style="color: red;"&gt;N'E:\DATA_Release\DatabaseName3.mdf'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;MOVE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: red;"&gt;N'Log'&lt;/span&gt;
&lt;span style="color: blue;"&gt;TO&lt;/span&gt; &lt;span style="color: red;"&gt;N'E:\LOG_Release\DatabaseName3.LDF'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .5in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;NOUNLOAD&lt;/span&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;,&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;&amp;nbsp;
&lt;span style="color: magenta;"&gt;REPLACE&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&amp;nbsp; &lt;span style="color: green;"&gt;STATS&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; 10&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
View which Databases are encrypted&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: magenta;"&gt;db_name&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;database_id&lt;span style="color: grey;"&gt;),&lt;/span&gt;
encryption_state&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .5in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;FROM&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt; &lt;span style="color: green;"&gt;sys&lt;/span&gt;&lt;span style="color: grey;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;dm_database_encryption_keys&lt;/span&gt; &lt;span style="color: blue;"&gt;with
&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;nolock&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
System Tables to view the encryption keys&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys&lt;/span&gt;&lt;span style="color: grey;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;symmetric_keys&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys&lt;/span&gt;&lt;span style="color: grey;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;certificates&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .5in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys&lt;/span&gt;&lt;span style="color: grey;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;dm_database_encryption_keys&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Remove Encryption from Database &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;ALTER&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
[DatabaseName1]&lt;span style="color: grey;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;SET&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;ENCRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;OFF&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;use&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; [DatabaseName1]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;Go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt;DROP&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; mso-no-proof: yes;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt;
&lt;span style="color: blue;"&gt;ENCRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-left: .5in;"&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8.0pt; line-height: 115%; mso-no-proof: yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-2514707614741146224?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/2514707614741146224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=2514707614741146224' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/2514707614741146224?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/2514707614741146224?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/05/database-encryption-with-db.html' title='Database Encryption with DB Certificates'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;A08CRX86eCp7ImA9WhVWE0s.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-7182444428457878718</id><published>2012-04-25T09:04:00.001-07:00</published><updated>2012-04-25T09:04:24.110-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-04-25T09:04:24.110-07:00</app:edited><title>list of failed jobs</title><content type='html'>&lt;br /&gt;
SELECT name FROM msdb.dbo.sysjobs A, msdb.dbo.sysjobservers B WHERE A.job_id = B.job_id AND B.last_run_outcome = 0&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-7182444428457878718?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/7182444428457878718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=7182444428457878718' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/7182444428457878718?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/7182444428457878718?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/04/list-of-failed-jobs.html' title='list of failed jobs'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DU4AQHs8fip7ImA9WhVWEkw.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-712499018793882525</id><published>2012-04-23T14:52:00.001-07:00</published><updated>2012-04-23T14:52:21.576-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-04-23T14:52:21.576-07:00</app:edited><title>Querying the SQL Server System Catalog FAQ</title><content type='html'>&lt;br /&gt;
&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the tables that do not have a clustered index in a specified database?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following queries, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid database name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_37011c39-3bb6-4e5c-8681-6cc09f66585c" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(t.schema_id) AS schema_name, t.name AS table_name
FROM sys.tables AS t
WHERE NOT EXISTS 
   (
     SELECT * FROM sys.indexes AS i
     WHERE i.object_id = t.object_id
     AND i.type = 1  -- or type_desc = 'CLUSTERED'
   )
ORDER BY schema_name, table_name;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Or, you can use the&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;OBJECTPROPERTY&lt;/span&gt;&amp;nbsp;function as shown in the following example.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_dc11caed-da7b-4d4b-988c-f52a0bbcdd44" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(schema_id) AS schema_name, name AS table_name
FROM sys.tables 
WHERE OBJECTPROPERTY(object_id,'TableHasClustIndex') = 0
ORDER BY schema_id, name;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ2" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the owners of entities contained in a specified schema?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name&gt;&lt;/schema_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_c95c460b-d1ac-4164-8650-e7ffd63ab77b" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT 'OBJECT' AS entity_type
    ,USER_NAME(OBJECTPROPERTY(object_id, 'OwnerId')) AS owner_name
    ,name 
FROM sys.objects WHERE SCHEMA_NAME(schema_id) = '&lt;schema_name&gt;'
UNION 
SELECT 'TYPE' AS entity_type
    ,USER_NAME(TYPEPROPERTY(SCHEMA_NAME(schema_id) + '.' + name, 'OwnerId')) AS owner_name
    ,name 
FROM sys.types WHERE SCHEMA_NAME(schema_id) = '&lt;schema_name&gt;' 
UNION
SELECT 'XML SCHEMA COLLECTION' AS entity_type 
    ,COALESCE(USER_NAME(xsc.principal_id),USER_NAME(s.principal_id)) AS owner_name
    ,xsc.name 
FROM sys.xml_schema_collections AS xsc JOIN sys.schemas AS s
    ON s.schema_id = xsc.schema_id
WHERE s.name = '&lt;schema_name&gt;';
GO


&lt;/schema_name&gt;&lt;/schema_name&gt;&lt;/schema_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ3" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the tables that do not have a primary key?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following queries, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid database name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_86c9702f-8e45-4f24-a634-7a7ea3718bbb" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(t.schema_id) AS schema_name
    ,t.name AS table_name
FROM sys.tables t 
WHERE object_id NOT IN 
   (
    SELECT parent_object_id 
    FROM sys.key_constraints 
    WHERE type_desc = 'PRIMARY_KEY_CONSTRAINT' -- or type = 'PK'
    );
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Or, you can run the following query.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_57f1fb97-82f2-4518-94e8-55910ebcd0da" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(schema_id) AS schema_name
    ,name AS table_name 
FROM sys.tables 
WHERE OBJECTPROPERTY(object_id,'TableHasPrimaryKey') = 0
ORDER BY schema_name, table_name;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ4" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the tables that do not have an index?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid database name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_c5857279-4130-43b7-baac-ae48579c3135" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(schema_id) AS schema_name
    ,name AS table_name
FROM sys.tables 
WHERE OBJECTPROPERTY(object_id,'IsIndexed') = 0
ORDER BY schema_name, table_name;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ5" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the tables that have an identity column?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid database name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_3b479513-e3d0-47c9-a96d-87b46e98a7eb" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(schema_id) AS schema_name
    , t.name AS table_name
    , c.name AS column_name
FROM sys.tables AS t
JOIN sys.identity_columns c ON t.object_id = c.object_id
ORDER BY schema_name, table_name;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Or, you can run the following query.&lt;br /&gt;
&lt;div class="alert" style="background-color: #fcfec5; border-bottom-color: rgb(187, 187, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(187, 187, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(187, 187, 187); border-top-style: solid; border-top-width: 1px; margin-bottom: 10px;"&gt;
&lt;table style="border-bottom-color: rgb(187, 187, 187); border-bottom-style: solid; border-bottom-width: 0px; border-collapse: collapse; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 0px; border-right-color: rgb(187, 187, 187); border-right-style: solid; border-right-width: 0px; border-top-color: rgb(187, 187, 187); border-top-style: solid; border-top-width: 0px; width: 1240px;"&gt;&lt;tbody&gt;
&lt;tr style="vertical-align: top;"&gt;&lt;th align="left" style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-bottom-color: rgb(187, 187, 187); border-bottom-style: hidden; border-bottom-width: 0px; border-collapse: collapse; border-left-color: rgb(187, 187, 187); border-left-style: hidden; border-left-width: 0px; border-right-color: rgb(187, 187, 187); border-right-style: hidden; border-right-width: 0px; border-top-color: rgb(187, 187, 187); border-top-style: hidden; border-top-width: 0px; font-size: 1.077em; height: 21px; padding-bottom: 1px; padding-left: 11px; padding-right: 11px; padding-top: 10px; text-align: left;"&gt;&lt;img alt="Note" id="alert_note" src="http://i.msdn.microsoft.com/dynimg/IC101471.gif" style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; padding-right: 5px;" title="Note" xmlns="" /&gt;&amp;nbsp;&lt;strong&gt;Note&lt;/strong&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr style="vertical-align: top;"&gt;&lt;td style="border-bottom-color: rgb(187, 187, 187); border-bottom-style: solid; border-bottom-width: 0px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 0px; border-right-color: rgb(187, 187, 187); border-right-style: solid; border-right-width: 0px; border-top-color: rgb(187, 187, 187); border-top-style: solid; border-top-width: 0px; line-height: 18px; margin-bottom: 1px; margin-left: 1px; margin-right: 1px; margin-top: 1px; padding-bottom: 10px; padding-left: 11px; padding-right: 11px; padding-top: 1px;"&gt;&lt;div style="padding-top: 13px; position: relative;"&gt;
This query does not return the name of the columns.&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_084a89df-af8f-4652-8a38-d3ad8643349c" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(schema_id) AS schema_name
    ,name AS table_name 
FROM sys.tables 
WHERE OBJECTPROPERTY(object_id,'TableHasIdentity') = 1
ORDER BY schema_name, table_name;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ7" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the data types of the columns of a specified table?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.table_name&gt;&lt;/schema_name.table_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_e0708abf-eb08-4ab7-bfd6-c93141885498" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT c.name AS column_name
    ,c.column_id
    ,SCHEMA_NAME(t.schema_id) AS type_schema
    ,t.name AS type_name
    ,t.is_user_defined
    ,t.is_assembly_type
    ,c.max_length
    ,c.precision
    ,c.scale
FROM sys.columns AS c 
JOIN sys.types AS t ON c.user_type_id=t.user_type_id
WHERE c.object_id = OBJECT_ID('&lt;schema_name.table_name&gt;')
ORDER BY c.column_id;
GO


&lt;/schema_name.table_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ8" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the dependencies on a specified function?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.function_name&gt;&lt;/schema_name.function_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_1e29de76-1b2d-4639-8c2b-6b8db1c48654" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_NAME(object_id) AS referencing_object_name
    ,COALESCE(COL_NAME(object_id, column_id), '(n/a)') AS referencing_column_name
    ,*
FROM sys.sql_dependencies
WHERE referenced_major_id = OBJECT_ID('&lt;schema_name.function_name&gt;')
ORDER BY OBJECT_NAME(object_id), COL_NAME(object_id, column_id);
GO 


&lt;/schema_name.function_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ9" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the stored procedures in a database?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_27778288-4532-45f2-9d95-a74143159f31" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT name AS procedure_name 
    ,SCHEMA_NAME(schema_id) AS schema_name
    ,type_desc
    ,create_date
    ,modify_date
FROM sys.procedures;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ10" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the parameters for a specified stored procedure or function?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.object_name&gt;&lt;/schema_name.object_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_0948113b-f4f3-4f61-8f48-4f14b33f4999" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(schema_id) AS schema_name
    ,o.name AS object_name
    ,o.type_desc
    ,p.parameter_id
    ,p.name AS parameter_name
    ,TYPE_NAME(p.user_type_id) AS parameter_type
    ,p.max_length
    ,p.precision
    ,p.scale
    ,p.is_output
FROM sys.objects AS o
INNER JOIN sys.parameters AS p ON o.object_id = p.object_id
WHERE o.object_id = OBJECT_ID('&lt;schema_name.object_name&gt;')
ORDER BY schema_name, o.object_name, p.parameter_id;
GO


&lt;/schema_name.object_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ12" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the user-defined functions in a database?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid database name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_010bb5b2-c479-4a09-a160-473722f51973" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT name AS function_name 
  ,SCHEMA_NAME(schema_id) AS schema_name
  ,type_desc
  ,create_date
  ,modify_date
FROM sys.objects
WHERE type_desc LIKE '%FUNCTION%';
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ13" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all views in a database?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid database name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_9f945613-cedf-4ca1-8672-378cd9e50c9d" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT name AS view_name 
  ,SCHEMA_NAME(schema_id) AS schema_name
  ,OBJECTPROPERTYEX(object_id,'IsIndexed') AS IsIndexed
  ,OBJECTPROPERTYEX(object_id,'IsIndexable') AS IsIndexable
  ,create_date
  ,modify_date
FROM sys.views;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ6" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the entities that have been modified in the last N days?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;n_days&gt;&lt;/n_days&gt;&lt;/span&gt;&amp;nbsp;with valid values.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_227e703a-d30c-4d56-9b00-a0a7d9508744" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT name AS object_name 
  ,SCHEMA_NAME(schema_id) AS schema_name
  ,type_desc
  ,create_date
  ,modify_date
FROM sys.objects
WHERE modify_date &amp;gt; GETDATE() - &lt;n_days&gt;
ORDER BY modify_date;
GO


&lt;/n_days&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ14" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the LOB data types of a specified table?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.table_name&gt;&lt;/schema_name.table_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_cf41069f-6d86-45ff-9ba2-c575a2333843" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT name AS column_name 
    ,column_id 
    ,TYPE_NAME(user_type_id) AS type_name
    ,max_length
    ,CASE 
       WHEN max_length = -1 AND TYPE_NAME(user_type_id) &amp;lt;&amp;gt; 'xml'
            THEN 1
            ELSE 0
     END AS [(max)]
FROM sys.columns
WHERE object_id=OBJECT_ID('&lt;schema_name.table_name&gt;') 
    AND ( TYPE_NAME(user_type_id) IN ('xml','text', 'ntext','image')
         OR (TYPE_NAME(user_type_id) IN ('varchar','nvarchar','varbinary')
         AND max_length = -1)
        );
GO


&lt;/schema_name.table_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ15" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I view the definition of a module?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.object_name&gt;&lt;/schema_name.object_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_00563a10-42bc-42a1-9901-d32477118fde" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT definition
FROM sys.sql_modules
WHERE object_id = OBJECT_ID('&lt;schema_name.object_name&gt;');
GO


&lt;/schema_name.object_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Or, you can use the&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;OBJECT&lt;/span&gt;_&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;DEFINITION&amp;nbsp;&lt;/span&gt;function as shown in the following example.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_e285dc3b-fa2f-4a16-8aa8-3686aa82e50f" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_DEFINITION (OBJECT_ID('&lt;schema_name.object_name&gt;')) AS ObjectDefinition;
GO


&lt;/schema_name.object_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ19" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I view the definition of a server-level trigger?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_8349b330-cd12-40b7-a1a4-2a97a914e14e" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;SELECT definition
FROM sys.server_sql_modules;
GO


&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ16" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the columns of a primary key for a specified table?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.table_name&gt;&lt;/schema_name.table_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_27be1b5b-dd7a-4933-841e-bc6aec349743" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT i.name AS index_name
    ,ic.index_column_id
    ,key_ordinal
    ,c.name AS column_name
    ,TYPE_NAME(c.user_type_id)AS column_type 
    ,is_identity
FROM sys.indexes AS i
INNER JOIN sys.index_columns AS ic 
    ON i.object_id = ic.object_id AND i.index_id = ic.index_id
INNER JOIN sys.columns AS c 
    ON ic.object_id = c.object_id AND c.column_id = ic.column_id
WHERE i.is_primary_key = 1 
    AND i.object_id = OBJECT_ID('&lt;schema_name.table_name&gt;');
GO


&lt;/schema_name.table_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Or, you can use the&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;COL_NAME&lt;/span&gt;&amp;nbsp;function as shown in the following example.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_b263374f-6fda-40d9-a97d-4ad0dd51625e" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT i.name AS index_name
    ,COL_NAME(ic.object_id,ic.column_id) AS column_name
    ,ic.index_column_id
    ,key_ordinal
FROM sys.indexes AS i
INNER JOIN sys.index_columns AS ic 
    ON i.object_id = ic.object_id AND i.index_id = ic.index_id
WHERE i.is_primary_key = 1 
    AND i.object_id = OBJECT_ID('&lt;schema_name.table_name&gt;');
GO


&lt;/schema_name.table_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ17" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the columns of a foreign key for a specified table?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.table_name&gt;&lt;/schema_name.table_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_29471f2f-fb6c-44f5-9c3d-3512a7bcf66b" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT 
    f.name AS foreign_key_name
   ,OBJECT_NAME(f.parent_object_id) AS table_name
   ,COL_NAME(fc.parent_object_id, fc.parent_column_id) AS constraint_column_name
   ,OBJECT_NAME (f.referenced_object_id) AS referenced_object
   ,COL_NAME(fc.referenced_object_id, fc.referenced_column_id) AS referenced_column_name
   ,is_disabled
   ,delete_referential_action_desc
   ,update_referential_action_desc
FROM sys.foreign_keys AS f
INNER JOIN sys.foreign_key_columns AS fc 
   ON f.object_id = fc.constraint_object_id 
WHERE f.parent_object_id = OBJECT_ID('&lt;schema_name.table_name&gt;');


&lt;/schema_name.table_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ18" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the permissions granted or denied to a specified principal?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
The following example creates a function to return the name of the entity on which the permissions are checked. The function is invoked in the queries that follow. The function must be created in every database in which you want to check permissions.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_9a9412c0-e1c8-4c48-be4c-2d99bbf70fcb" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;-- Create a function to return the name of the entity on which the permissions are checked.
IF OBJECT_ID (N'dbo.entity_instance_name', N'FN') IS NOT NULL
    DROP FUNCTION dbo.entity_instance_name;
GO
CREATE FUNCTION dbo.entity_instance_name(@class_desc nvarchar(60), @major_id int) 
RETURNS sysname AS
BEGIN
    DECLARE @the_entity_name sysname
    SELECT @the_entity_name = CASE
        WHEN @class_desc = 'DATABASE' THEN DB_NAME()
        WHEN @class_desc = 'SCHEMA' THEN SCHEMA_NAME(@major_id)
        WHEN @class_desc = 'OBJECT_OR_COLUMN' THEN OBJECT_NAME(@major_id)
        WHEN @class_desc = 'DATABASE_PRINCIPAL' THEN USER_NAME(@major_id)
        WHEN @class_desc = 'ASSEMBLY' THEN 
            (SELECT name FROM sys.assemblies WHERE assembly_id=@major_id)
        WHEN @class_desc = 'TYPE' THEN TYPE_NAME(@major_id)
        WHEN @class_desc = 'XML_SCHEMA_COLLECTION' THEN 
            (SELECT name FROM sys.xml_schema_collections
              WHERE xml_collection_id=@major_id)
        WHEN @class_desc = 'MESSAGE_TYPE' THEN 
            (SELECT name FROM sys.service_message_types WHERE message_type_id=@major_id)
        WHEN @class_desc = 'SERVICE_CONTRACT' THEN 
           (SELECT name FROM sys.service_contracts
              WHERE service_contract_id=@major_id)
        WHEN @class_desc = 'SERVICE' THEN
          (SELECT name FROM sys.services WHERE service_id=@major_id)
        WHEN @class_desc = 'REMOTE_SERVICE_BINDING' THEN
          (SELECT name FROM sys.remote_service_bindings
             WHERE remote_service_binding_id=@major_id)
        WHEN @class_desc = 'ROUTE' THEN
          (SELECT name FROM sys.routes WHERE route_id=@major_id)
        WHEN @class_desc = 'FULLTEXT_CATALOG' THEN
          (SELECT name FROM sys.fulltext_catalogs WHERE fulltext_catalog_id=@major_id)
        WHEN @class_desc = 'SYMMETRIC_KEY' THEN
          (SELECT name FROM sys.symmetric_keys WHERE symmetric_key_id=@major_id)
        WHEN @class_desc = 'CERTIFICATE' THEN
          (SELECT name FROM sys.certificates WHERE certificate_id=@major_id)
        WHEN @class_desc = 'ASYMMETRIC_KEY' THEN
          (SELECT name FROM sys.asymmetric_keys WHERE asymmetric_key_id=@major_id)
        WHEN @class_desc = 'SERVER' THEN 
             (SELECT name FROM sys.servers WHERE server_id=@major_id)
        WHEN @class_desc = 'SERVER_PRINCIPAL' THEN SUSER_NAME(@major_id)
        WHEN @class_desc = 'ENDPOINT' THEN 
             (SELECT name FROM sys.endpoints WHERE endpoint_id=@major_id)      
        ELSE '?'
    END
    RETURN @the_entity_name
END;
GO
-- Return server-level permissions for the user.
SELECT class
    ,class_desc
    ,dbo.entity_instance_name(class_desc, major_id) AS entity_name 
    ,minor_id
    ,SUSER_NAME(grantee_principal_id) AS grantee
    ,SUSER_NAME(grantor_principal_id) AS grantor
    ,type
    ,permission_name
    ,state_desc 
FROM sys.server_permissions 
WHERE grantee_principal_id = SUSER_ID('public');
GO
-- Return database-level permissions for the user.
SELECT class
    ,class_desc
    ,dbo.entity_instance_name(class_desc , major_id) AS entity_name 
    ,minor_id
    ,USER_NAME(grantee_principal_id) AS grantee
    ,USER_NAME(grantor_principal_id) AS grantor
    ,type
    ,permission_name
    ,state_desc   
FROM  sys.database_permissions 
WHERE grantee_principal_id = DATABASE_PRINCIPAL_ID('public');
GO


&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ20" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I determine if a column is used in a computed column expression?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.table_name&gt;&lt;/schema_name.table_name&gt;&lt;/span&gt;, and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;column_name&lt; span=""&gt;&amp;gt; with valid names.&lt;/column_name&lt;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_b5c77272-7a0a-4973-9372-a2a2fe9c3d51" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_NAME(object_id) AS object_name
    ,COL_NAME(object_id, column_id) AS computed_column 
    ,class_desc
    ,is_selected
    ,is_updated
    ,is_select_all
FROM sys.sql_dependencies
WHERE referenced_major_id = OBJECT_ID('&lt;schema_name.table_name&gt;')
    AND referenced_minor_id = COLUMNPROPERTY(referenced_major_id, '&lt;column_name&gt;', 'ColumnId')
    AND class = 1;
GO


&lt;/column_name&gt;&lt;/schema_name.table_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ21" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the columns that are used in a computed column expression?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_47a18f7d-a3b8-4c5b-9bad-0ee59c357b8d" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_NAME(d.referenced_major_id) AS object_name
    ,COL_NAME(d.referenced_major_id, d.referenced_minor_id) AS column_name
    ,OBJECT_NAME(referenced_major_id) AS dependent_object_name 
    ,COL_NAME(d.object_id, d.column_id) AS dependent_computed_column
    ,cc.definition AS computed_column_definition
FROM sys.sql_dependencies AS d
JOIN sys.computed_columns AS cc 
    ON cc.object_id = d.object_id AND cc.column_id = d.column_id AND d.object_id=d.referenced_major_id     
WHERE d.class = 1
ORDER BY object_name, column_name;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ22" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the columns that depend on a specified CLR user-defined type or alias type?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.data&lt; span=""&gt;_&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;type&lt;/span&gt;_&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;name&amp;gt;&lt;/span&gt;&amp;nbsp;with a valid, schema-qualified CLR user-defined type, or schema-qualified alias type name. The following query requires membership in the&amp;nbsp;&lt;span class="input" style="font-weight: 700;"&gt;db_owner&lt;/span&gt;&amp;nbsp;role or permissions to see all dependent column and computed column metadata in the database.&lt;/schema_name.data&lt;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_c1a66a79-9a86-422e-8cee-e671f8a04dee" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_NAME(object_id) AS object_name 
    ,c.name AS column_name 
    ,SCHEMA_NAME(t.schema_id) AS schema_name
    ,TYPE_NAME(c.user_type_id) AS user_type_name
    ,c.max_length
    ,c.precision
    ,c.scale
    ,c.is_nullable
    ,c.is_computed
FROM sys.columns AS c
INNER JOIN sys.types AS t ON c.user_type_id = t.user_type_id
WHERE c.user_type_id = TYPE_ID('&lt;schema_name.data_type_name&gt;'); 
GO


&lt;/schema_name.data_type_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
The following query returns a restricted and narrow view of columns dependent on a CLR user-defined type or alias, but the result set is visible to the&amp;nbsp;&lt;strong&gt;public&lt;/strong&gt;&amp;nbsp;role. You can use this query if you have granted REFERENCE permissions on your user-defined type to others and you do not have permission to view the metadata of the objects others have created that use the type.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_837bc865-181d-44f4-8efb-e1c3f0742e0f" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_NAME(object_id) AS object_name 
    ,COL_NAME(object_id, column_id) AS column_name
    ,TYPE_NAME(user_type_id) AS user_type
FROM sys.column_type_usages
WHERE user_type_id = TYPE_ID('&lt;schema_name.data_type_name&gt;');
GO


&lt;/schema_name.data_type_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ23" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the computed columns that depend on a specified CLR user-defined type or alias type?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.data_type_name&gt;&lt;/schema_name.data_type_name&gt;&lt;/span&gt;&amp;nbsp;with a valid, schema-qualified CLR user-defined type, alias type name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_6a3f28d3-4332-491a-8083-d1ee2af70ed4" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_NAME(object_id) AS object_name
    ,COL_NAME(object_id, column_id) AS column_name
FROM sys.sql_dependencies
WHERE referenced_major_id = TYPE_ID('&lt;schema_name.data_type_name&gt;')
    AND class = 2 -- schema-bound references to type
    AND OBJECTPROPERTY(object_id, 'IsTable') = 1;   -- exclude non-table dependencies 


&lt;/schema_name.data_type_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ24" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the parameters that depend on a specified CLR user-defined type or alias type?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema&lt; span=""&gt;_&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;name.data_type&lt;/span&gt;_&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;name&amp;gt;&lt;/span&gt;&amp;nbsp;with a valid, schema-qualified CLR user-defined type, alias type name. The following query requires membership in the&amp;nbsp;&lt;span class="input" style="font-weight: 700;"&gt;db_owner&lt;/span&gt;&amp;nbsp;role or permissions to see all dependent column and computed column metadata in the database.&lt;/schema&lt;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_6921c654-c72a-4432-88a0-88fd13206bf2" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_NAME(object_id) AS object_name
    ,NULL AS procedure_number
    ,name AS param_name
    ,parameter_id AS param_num
    ,TYPE_NAME(p.user_TYPE_ID) AS type_name
FROM sys.parameters AS p
WHERE p.user_TYPE_ID = TYPE_ID('&lt;schema_name.data_type_name&gt;')
UNION 
SELECT OBJECT_NAME(object_id) AS object_name
    ,procedure_number
    ,name AS param_name
    ,parameter_id AS param_num
    ,TYPE_NAME(p.user_TYPE_ID) AS type_name
FROM sys.numbered_procedure_parameters AS p
WHERE p.user_TYPE_ID = TYPE_ID('&lt;schema_name.data_type_name&gt;')
ORDER BY object_name, procedure_number, param_num;
GO



&lt;/schema_name.data_type_name&gt;&lt;/schema_name.data_type_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
The following query returns a restricted and narrow view of parameters that depend on a CLR user-defined type or alias, but the result set is visible to the&amp;nbsp;&lt;strong&gt;public&lt;/strong&gt;&amp;nbsp;role. You can use this query if you have granted REFERENCE permissions on your user-defined type to others and you do not have permission to view the metadata of the objects others have created that use the type.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_d139a746-b49f-4230-86db-51eb4239b4b1" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_NAME(object_id) AS object_name
    ,parameter_id
    ,TYPE_NAME(user_type_id) AS type_name
FROM sys.parameter_type_usages 
WHERE user_type_id = TYPE_ID('&lt;schema_name.data_type_name&gt;');
GO


&lt;/schema_name.data_type_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ25" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the CHECK constraints that depend on a specified CLR user-defined type?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema&lt; span=""&gt;_&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;name.data_type_name&amp;gt;&lt;/span&gt;&amp;nbsp;with a valid, schema-qualified CLR user-defined type name.&lt;/schema&lt;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_5b3fe40c-eae0-4b7c-a7c2-336c02925758" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(o.schema_id) AS schema_name
    ,OBJECT_NAME(o.parent_object_id) AS table_name
    ,OBJECT_NAME(o.object_id) AS constraint_name
FROM sys.sql_dependencies AS d
JOIN sys.objects AS o ON o.object_id = d.object_id
WHERE referenced_major_id = TYPE_ID('&lt;schema_name.data_type_name&gt;')
    AND class = 2 -- schema-bound references to type
    AND OBJECTPROPERTY(o.object_id, 'IsCheckCnst') = 1; -- exclude non-CHECK dependencies
GO


&lt;/schema_name.data_type_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ26" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the views, Transact-SQL functions, and Transact-SQL stored procedures that depend on a specified CLR user-defined type or alias type?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.data_type_name&gt;&lt;/schema_name.data_type_name&gt;&lt;/span&gt;&amp;nbsp;with a valid, schema-qualified CLR user-defined type, alias type name.&lt;br /&gt;
&lt;div style="margin-top: -6px;"&gt;
The parameters defined in a function or procedure are implicitly schema bound. Therefore, parameters that depend on a CLR user-defined type or alias type can be viewed by using the&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/ms174402.aspx" style="color: #960bb4; text-decoration: none;"&gt;sys.sql_dependencies&lt;/a&gt;catalog view. Procedures and triggers are not schema bound. This means that dependencies between any expression defined in the body of the procedure or trigger and a CLR user-defined type or alias type is not maintained. Schema bound views and schema bound user-defined functions that have expressions that depend on a CLR user-defined type or alias type are maintained in the&amp;nbsp;&lt;strong&gt;sys.sql_dependencies&lt;/strong&gt;&amp;nbsp;catalog view. Dependencies between types and CLR functions and CLR procedures are not maintained.&lt;/div&gt;
&lt;div style="margin-top: -6px;"&gt;
The following query returns all schema-bound dependencies in views, Transact-SQL functions, and Transact-SQL stored procedures for a specified CLR user-defined type or alias type.&lt;/div&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_e176bb03-02ab-43ad-864e-edce49522c04" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(o.schema_id) AS dependent_object_schema
  ,OBJECT_NAME(o.object_id) AS dependent_object_name
  ,o.type_desc AS dependent_object_type
  ,d.class_desc AS kind_of_dependency
  ,TYPE_NAME (d.referenced_major_id) AS type_name
FROM sys.sql_dependencies AS d 
JOIN sys.objects AS o
  ON d.object_id = o.object_id
  AND o.type IN ('FN','IF','TF', 'V', 'P')
WHERE d.class = 2 -- dependencies on types
  AND d.referenced_major_id = TYPE_ID('&lt;schema_name.data_type_name&gt;')
ORDER BY dependent_object_schema, dependent_object_name;
GO


&lt;/schema_name.data_type_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ27" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the constraints for a specified table?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.table_name&gt;&lt;/schema_name.table_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_46386afb-a5ea-46df-a0fd-e98029305262" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_NAME(object_id) as constraint_name
    ,SCHEMA_NAME(schema_id) AS schema_name
    ,OBJECT_NAME(parent_object_id) AS table_name
    ,type_desc
    ,create_date
    ,modify_date
    ,is_ms_shipped
    ,is_published
    ,is_schema_published
FROM sys.objects
WHERE type_desc LIKE '%CONSTRAINT' 
    AND parent_object_id = OBJECT_ID('&lt;schema_name.table_name&gt;');
GO


&lt;/schema_name.table_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ28" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the indexes for a specified table?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.table_name&gt;&lt;/schema_name.table_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_7f287173-1aef-4111-be4c-61803b0f0c1f" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT i.name AS index_name
    ,i.type_desc
    ,is_unique
    ,ds.type_desc AS filegroup_or_partition_scheme
    ,ds.name AS filegroup_or_partition_scheme_name
    ,ignore_dup_key
    ,is_primary_key
    ,is_unique_constraint
    ,fill_factor
    ,is_padded
    ,is_disabled
    ,allow_row_locks
    ,allow_page_locks
FROM sys.indexes AS i
INNER JOIN sys.data_spaces AS ds ON i.data_space_id = ds.data_space_id
WHERE is_hypothetical = 0 AND i.index_id &amp;lt;&amp;gt; 0 
AND i.object_id = OBJECT_ID('&lt;schema_name.table_name&gt;');
GO


&lt;/schema_name.table_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ30" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the objects that have a specified column name?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;column_name&gt;&lt;/column_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_a8abc0da-51f2-497f-afb7-ca0a5b9bd791" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_NAME(object_id)
FROM sys.columns
WHERE name = '&lt;column_name&gt;';
GO


&lt;/column_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Or&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_bba4b768-5c08-48f8-a234-b7ad56f6ba73" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(o.schema_id) AS schema_name 
    ,o.name AS object_name
    ,type_desc
FROM sys.objects AS o
INNER JOIN sys.columns AS c ON o.object_id = c.object_id
WHERE c.name = '&lt;column_name&gt;';
GO


&lt;/column_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ31" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the user-defined tables in a specified database?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_21f7bbcd-0270-49c3-8e2c-5ab82b4f2acc" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT * 
FROM sys.tables;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ32" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the tables and indexes that are partitioned?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_d5165596-94b8-42f2-abca-4045abaa5221" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT SCHEMA_NAME(o.schema_id) AS schema_name
    ,OBJECT_NAME(p.object_id) AS table_name
    ,i.name AS index_name
    ,p.partition_number
    ,rows 
FROM sys.partitions AS p
INNER JOIN sys.indexes AS i ON p.object_id = i.object_id AND p.index_id = i.index_id
INNER JOIN sys.partition_schemes ps ON i.data_space_id=ps.data_space_id
INNER JOIN sys.objects AS o ON o.object_id = i.object_id
ORDER BY index_name, partition_number;
GO


&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ33" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the statistics on a specified object?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.object_name&gt;&lt;/schema_name.object_name&gt;&lt;/span&gt;&amp;nbsp;with a valid table, indexed view, or table-valued function name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_16fcbdd2-f0b7-4d22-b5e4-949dd5e3d3ad" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT name AS statistics_name
    ,stats_id
    ,auto_created
    ,user_created
    ,no_recompute
FROM sys.stats
WHERE object_id = OBJECT_ID('&lt;schema_name.object_name&gt;');
GO


&lt;/schema_name.object_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ34" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find all the statistics and statistics columns on a specified object?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;with a valid name and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.object_name&gt;&lt;/schema_name.object_name&gt;&lt;/span&gt;&amp;nbsp;with a valid table, indexed view, or table-valued function name.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_67a0facf-58bb-491d-a599-40a066fda08d" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT s.name AS statistics_name
    ,c.name AS column_name
    ,sc.stats_column_id
FROM sys.stats AS s
INNER JOIN sys.stats_columns AS sc 
    ON s.object_id = sc.object_id AND s.stats_id = sc.stats_id
INNER JOIN sys.columns AS c 
    ON sc.object_id = c.object_id AND c.column_id = sc.column_id
WHERE s.object_id = OBJECT_ID('&lt;schema_name.object_name&gt;');
GO


&lt;/schema_name.object_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx#_TOP" style="color: #960bb4; text-decoration: none;"&gt;TOP&lt;/a&gt;&lt;/div&gt;
&lt;a href="" id="_FAQ35" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;span style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;"&gt;&lt;/span&gt;&lt;h3 class="subHeading" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-size: 1.077em; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
How do I find the definition of a view?&lt;/h3&gt;
&lt;div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; text-align: left;" xmlns="http://www.w3.org/1999/xhtml"&gt;
Before you run the following query, replace&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;database_name&gt;&lt;/database_name&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;&lt;schema_name.object_name&gt;&lt;/schema_name.object_name&gt;&lt;/span&gt;&amp;nbsp;with valid names.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_4dbe8eb6-6f26-466f-b2f0-ec6b9c92259c" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT definition
FROM sys.sql_modules
WHERE object_id = OBJECT_ID('&lt;schema_name.object_name&gt;');
GO


&lt;/schema_name.object_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Or, you can use the&amp;nbsp;&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;OBJECT&lt;/span&gt;_&lt;span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;"&gt;DEFINITION&amp;nbsp;&lt;/span&gt;function as shown in the following example.&lt;br /&gt;
&lt;div&gt;
&lt;div class="codeSnippetContainer" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;"&gt;
&lt;div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr" style="background-attachment: scroll; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: 0px 0px; background-repeat: repeat repeat; border-bottom-color: rgb(208, 210, 210); border-bottom-style: none; border-bottom-width: 2px; border-color: initial; border-image: initial; border-left-color: rgb(146, 146, 146); border-left-style: none; border-left-width: 1px; border-right-style: none; border-top-color: rgb(187, 187, 187); border-top-style: none; border-top-width: 1px; border-width: initial; color: #e66a38; float: left; font-weight: bold; height: 19px; left: 7px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 8px; padding-right: 8px; padding-top: 0px; position: relative; top: 10px; vertical-align: baseline; width: auto;"&gt;
&lt;a href="" style="color: #1364c4;"&gt;Transact-SQL&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; margin-bottom: 12px; position: relative; top: -3px;"&gt;
&lt;div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;"&gt;
&lt;div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_28d924c5-9112-47ce-bbf3-45911be8a09c" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 9px; padding-left: 21px; padding-right: 21px; padding-top: 9px; width: auto;"&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"&gt;USE &lt;database_name&gt;;
GO
SELECT OBJECT_DEFINITION (OBJECT_ID('&lt;schema_name.object_name&gt;')) AS ObjectDefinition;
GO


&lt;/schema_name.object_name&gt;&lt;/database_name&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
TOP&lt;a href="http://msdn.microsoft.com/en-us/library/ms345522.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms345522.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-712499018793882525?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/712499018793882525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=712499018793882525' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/712499018793882525?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/712499018793882525?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/04/querying-sql-server-system-catalog-faq.html' title='Querying the SQL Server System Catalog FAQ'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DEQBSX4_cSp7ImA9WhVWEkw.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-8864387405757080885</id><published>2012-04-23T14:25:00.001-07:00</published><updated>2012-04-23T14:25:58.049-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-04-23T14:25:58.049-07:00</app:edited><title>View / Grant / Revoke Security permissions</title><content type='html'>&lt;br /&gt;
--view security definitions&lt;br /&gt;
select sys.schemas.name 'Schema', sys.objects.name Object, sys.database_principals.name username, sys.database_permissions.type permissions_type,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;sys.database_permissions.permission_name,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;sys.database_permissions.state permission_state,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;sys.database_permissions.state_desc,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;state_desc + ' ' + permission_name + ' on ['+ sys.schemas.name + '].[' + sys.objects.name + '] to [' + sys.database_principals.name + ']' COLLATE LATIN1_General_CI_AS&lt;br /&gt;
&amp;nbsp;from sys.database_permissions&lt;br /&gt;
&amp;nbsp;join sys.objects on sys.database_permissions.major_id =&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;sys.objects.object_id&lt;br /&gt;
&amp;nbsp;join sys.schemas on sys.objects.schema_id = sys.schemas.schema_id&lt;br /&gt;
&amp;nbsp;join sys.database_principals on sys.database_permissions.grantee_principal_id =&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;sys.database_principals.principal_id&lt;br /&gt;
&amp;nbsp;order by 1, 2, 3, 5&lt;br /&gt;
&lt;br /&gt;
--revoke permission&lt;br /&gt;
select&lt;br /&gt;
'USE ['+DB_NAME()+']' + ' REVOKE VIEW DEFINITION ON [dbo].['+sys.objects.name+'] FROM ['+sys.database_principals.name+']'&lt;br /&gt;
,*&lt;br /&gt;
from sys.database_permissions&lt;br /&gt;
join sys.objects on sys.database_permissions.major_id = sys.objects.object_id&lt;br /&gt;
join sys.schemas on sys.objects.schema_id = sys.schemas.schema_id&lt;br /&gt;
join sys.database_principals on sys.database_permissions.grantee_principal_id = sys.database_principals.principal_id&lt;br /&gt;
where permission_name = 'VIEW DEFINITION'&lt;br /&gt;
and sys.database_principals.name = 'CSODMGMT\SQLAllDBAccess'&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-8864387405757080885?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/8864387405757080885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=8864387405757080885' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/8864387405757080885?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/8864387405757080885?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/04/view-grant-revoke-security-permissions.html' title='View / Grant / Revoke Security permissions'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0IDRHg_fSp7ImA9WhVXGEo.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-9019802350335944760</id><published>2012-04-19T14:39:00.001-07:00</published><updated>2012-04-19T14:39:35.645-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-04-19T14:39:35.645-07:00</app:edited><title>SQL Server Service Broker example on how to configure, send and receive messages</title><content type='html'>&lt;a href="http://www.mssqltips.com/sqlservertip/1836/sql-server-service-broker-example-on-how-to-configure-send-and-receive-messages/"&gt;SQL Server Service Broker example on how to configure, send and receive messages&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-9019802350335944760?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.mssqltips.com/sqlservertip/1836/sql-server-service-broker-example-on-how-to-configure-send-and-receive-messages/' title='SQL Server Service Broker example on how to configure, send and receive messages'/><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/9019802350335944760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=9019802350335944760' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/9019802350335944760?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/9019802350335944760?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/04/sql-server-service-broker-example-on.html' title='SQL Server Service Broker example on how to configure, send and receive messages'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D0cNRH44fSp7ImA9WhVXGEk.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-3410269528201119414</id><published>2012-04-19T07:18:00.001-07:00</published><updated>2012-04-19T07:18:15.035-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-04-19T07:18:15.035-07:00</app:edited><title>Comparing performance for the MERGE statement to SELECT, INSERT, UPDATE or DELETE</title><content type='html'>&lt;a href="http://www.mssqltips.com/sqlservertip/2651/comparing-performance-for-the-merge-statement-to-select-insert-update-or-delete/"&gt;Comparing performance for the MERGE statement to SELECT, INSERT, UPDATE or DELETE&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-3410269528201119414?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.mssqltips.com/sqlservertip/2651/comparing-performance-for-the-merge-statement-to-select-insert-update-or-delete/' title='Comparing performance for the MERGE statement to SELECT, INSERT, UPDATE or DELETE'/><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/3410269528201119414/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=3410269528201119414' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/3410269528201119414?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/3410269528201119414?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/04/comparing-performance-for-merge.html' title='Comparing performance for the MERGE statement to SELECT, INSERT, UPDATE or DELETE'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DEUFRH0zfCp7ImA9WhVQE0o.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-1084105124852073861</id><published>2012-04-02T07:16:00.001-07:00</published><updated>2012-04-02T07:16:55.384-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-04-02T07:16:55.384-07:00</app:edited><title>New columnstore index feature in SQL Server 2012</title><content type='html'>&lt;a href="http://www.mssqltips.com/sqlservertip/2666/new-columnstore-index-feature-in-sql-server-2012/?utm_source=dailynewsletter&amp;amp;utm_medium=email&amp;amp;utm_content=headline&amp;amp;utm_campaign=2012330"&gt;New columnstore index feature in SQL Server 2012&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-1084105124852073861?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.mssqltips.com/sqlservertip/2666/new-columnstore-index-feature-in-sql-server-2012/?utm_source=dailynewsletter&amp;utm_medium=email&amp;utm_content=headline&amp;utm_campaign=2012330' title='New columnstore index feature in SQL Server 2012'/><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/1084105124852073861/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=1084105124852073861' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/1084105124852073861?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/1084105124852073861?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/04/new-columnstore-index-feature-in-sql.html' title='New columnstore index feature in SQL Server 2012'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CUYAR3Y4fSp7ImA9WhVQEEg.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-8842194274704235148</id><published>2012-03-29T13:32:00.001-07:00</published><updated>2012-03-29T13:32:26.835-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-03-29T13:32:26.835-07:00</app:edited><title>SQL Jobs with Multiple schedules</title><content type='html'>&lt;br /&gt;
use msdb&lt;br /&gt;
go&lt;br /&gt;
/*&lt;br /&gt;
select * from sysjobs&lt;br /&gt;
select * from sysjobschedules&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
select a.job_id , a.name, &amp;nbsp;COUNT(*)&lt;br /&gt;
from sysjobs a&lt;br /&gt;
inner join sysjobschedules b on a.job_id = b.job_id&lt;br /&gt;
group by a.job_id , a.name&lt;br /&gt;
having COUNT(*) &amp;gt; 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
select c.name, b.*, a.*&lt;br /&gt;
from sysschedules a&lt;br /&gt;
inner join sysjobschedules b on a.schedule_id = b.schedule_id&lt;br /&gt;
inner join sysjobs c on c.job_id = b.job_id&lt;br /&gt;
where a.schedule_id in&lt;br /&gt;
(&lt;br /&gt;
select schedule_id from sysjobschedules&lt;br /&gt;
where job_id in&lt;br /&gt;
(&lt;br /&gt;
select a.job_id&lt;br /&gt;
from sysjobs a&lt;br /&gt;
inner join sysjobschedules b on a.job_id = b.job_id&lt;br /&gt;
group by a.job_id , a.name&lt;br /&gt;
having COUNT(*) &amp;gt; 1&lt;br /&gt;
)&lt;br /&gt;
)&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-8842194274704235148?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/8842194274704235148/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=8842194274704235148' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/8842194274704235148?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/8842194274704235148?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/03/sql-jobs-with-multiple-schedules.html' title='SQL Jobs with Multiple schedules'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CkINQ3Y5fCp7ImA9WhVRF0o.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-555226009556835194</id><published>2012-03-26T07:03:00.001-07:00</published><updated>2012-03-26T07:03:12.824-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-03-26T07:03:12.824-07:00</app:edited><title>Verify SQL Server Stored Procedures are the same on multiple servers</title><content type='html'>&lt;a href="http://www.mssqltips.com/sqlservertip/2626/verify-sql-server-stored-procedures-are-the-same-on-multiple-servers/?utm_source=dailynewsletter&amp;amp;utm_medium=email&amp;amp;utm_content=headline&amp;amp;utm_campaign=2012319"&gt;Verify SQL Server Stored Procedures are the same on multiple servers&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-555226009556835194?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.mssqltips.com/sqlservertip/2626/verify-sql-server-stored-procedures-are-the-same-on-multiple-servers/?utm_source=dailynewsletter&amp;utm_medium=email&amp;utm_content=headline&amp;utm_campaign=2012319' title='Verify SQL Server Stored Procedures are the same on multiple servers'/><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/555226009556835194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=555226009556835194' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/555226009556835194?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/555226009556835194?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/03/verify-sql-server-stored-procedures-are.html' title='Verify SQL Server Stored Procedures are the same on multiple servers'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CE4ARX44fyp7ImA9WhVREUU.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-159231261082486199</id><published>2012-03-19T11:49:00.001-07:00</published><updated>2012-03-19T11:49:04.037-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-03-19T11:49:04.037-07:00</app:edited><title>Long Running Queries Alert</title><content type='html'>&lt;br /&gt;
use master&lt;br /&gt;
go&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
exec sp_long_running_queries @longduration = 15 , @sendalertemail = 1&lt;br /&gt;
*/&lt;br /&gt;
ALTER procedure sp_long_running_queries&lt;br /&gt;
(&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;@longduration int = 15 -- minutes&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;, @sendalertemail int = 0&lt;br /&gt;
)&lt;br /&gt;
as&lt;br /&gt;
BEGIN&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;CREATE TABLE #_tmp_whoisactive&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;( [dd hh:mm:ss.mss] varchar(8000) NULL,[session_id] smallint NOT NULL,[sql_text] xml NULL,[login_name] nvarchar(128) NOT NULL,[wait_info] nvarchar(4000) NULL,[CPU] varchar(30) NULL,[tempdb_allocations] varchar(30) NULL,[tempdb_current] varchar(30) NULL,[blocking_session_id] smallint NULL,[reads] varchar(30) NULL,[writes] varchar(30) NULL,[physical_reads] varchar(30) NULL,[used_memory] varchar(30) NULL,[status] varchar(30) NOT NULL,[open_tran_count] varchar(30) NULL,[percent_complete] varchar(30) NULL,[host_name] nvarchar(128) NULL,[database_name] nvarchar(128) NULL,[program_name] nvarchar(128) NULL,[start_time] datetime NOT NULL,[login_time] datetime NULL,[request_id] int NULL,[collection_time] datetime NOT NULL)&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;exec sp_WhoIsActive @destination_table = '#_tmp_whoisactive'&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;--select datediff(mi,start_time,collection_time) , * from #_tmp_whoisactive where datediff(mi,start_time,collection_time) &amp;gt; @longduration&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;if @sendalertemail = 1 and exists (&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;select * from #_tmp_whoisactive where datediff(mi,start_time,collection_time) &amp;gt; @longduration)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;begin&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;DECLARE @tableHTML &amp;nbsp;NVARCHAR(MAX) , @subjectstring nvarchar(200);&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;SET @tableHTML =&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;N'&lt;br /&gt;
&lt;h1&gt;
Long Runing Queries on '+@@SERVERNAME+' executing over '+convert(nvarchar(10),@longduration)+' minutes&lt;/h1&gt;
' +&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;N'&lt;br /&gt;
' +&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;N'&lt;br /&gt;
' +&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;N'&lt;br /&gt;
' +&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;N'&lt;br /&gt;
' +&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;CAST ( ( SELECT td = [dd hh:mm:ss.mss], &amp;nbsp; &amp;nbsp; &amp;nbsp; '',&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;       &lt;/span&gt;td = session_id, '',&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;       &lt;/span&gt;td = login_name, '',&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;       &lt;/span&gt;td = database_name, '',&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;       &lt;/span&gt;td = host_name, '',&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;       &lt;/span&gt;td = Status&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt; &amp;nbsp;FROM #_tmp_whoisactive&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt; &amp;nbsp;where datediff(mi,start_time,collection_time) &amp;gt; @longduration&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt; &amp;nbsp;FOR XML PATH('tr'), TYPE&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;) AS NVARCHAR(MAX) ) +&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;N'&lt;br /&gt;
&lt;table border="1"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Time Elapsed&lt;/th&gt;&lt;th&gt;Session&lt;/th&gt;&lt;th&gt;Login Name&lt;/th&gt;&lt;th&gt;Database&lt;/th&gt;&lt;th&gt;Executing Host&lt;/th&gt;&lt;th&gt;Status&lt;/th&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
' ;&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;--print @tableHTML&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt; &amp;nbsp; &lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;set @subjectstring = 'Long Running Queries over '+convert(nvarchar(10),@longduration)+' min on SQL Server '+@@SERVERNAME&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;EXEC msdb.dbo.sp_send_dbmail&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;@profile_name = 'default',&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;@recipients = 'DLProductionDBA@cornerstoneondemand.com;jferris@csod.com',&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;--@recipients ='palexander@csod.com',&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;@body = @tableHTML,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;@body_format = 'HTML' ,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;@subject = @subjectstring;&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; &amp;nbsp; &lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;end&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;drop table #_tmp_whoisactive&lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-159231261082486199?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/159231261082486199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=159231261082486199' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/159231261082486199?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/159231261082486199?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/03/long-running-queries-alert.html' title='Long Running Queries Alert'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;Ak4CRXw4cCp7ImA9WhVSGU0.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-8668957209420012206</id><published>2012-03-16T07:42:00.001-07:00</published><updated>2012-03-16T07:42:44.238-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-03-16T07:42:44.238-07:00</app:edited><title>If Primary Key Exists</title><content type='html'>&lt;br /&gt;
SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE &amp;nbsp;CONSTRAINT_TYPE = 'PRIMARY KEY' AND TABLE_NAME = 'user_career_pref_date' AND TABLE_SCHEMA ='dbo'&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE &amp;nbsp;CONSTRAINT_TYPE = 'PRIMARY KEY' AND TABLE_NAME = 'user_career_pref_date' AND TABLE_SCHEMA ='dbo' )&lt;/div&gt;
&lt;div&gt;
begin&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;ALTER TABLE [dbo].[user_career_pref_date]&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; ADD CONSTRAINT [PK_user_career_pref_date] PRIMARY KEY CLUSTERED ([user_id] ASC, [question_id] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF);&lt;/div&gt;
&lt;div&gt;
end&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-8668957209420012206?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/8668957209420012206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=8668957209420012206' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/8668957209420012206?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/8668957209420012206?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/03/if-primary-key-exists.html' title='If Primary Key Exists'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CEEFR38-fyp7ImA9WhVSF0k.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-2351284419476517939</id><published>2012-03-14T09:27:00.001-07:00</published><updated>2012-03-14T09:30:16.157-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-03-14T09:30:16.157-07:00</app:edited><title>Proc to show expensive queries : sp_expensive_queries</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
USE [master]&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
SET ANSI_NULLS ON&lt;br /&gt;
GO&lt;br /&gt;
SET QUOTED_IDENTIFIER ON&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
ALTER procedure [dbo].[sp_expensive_queries]&lt;br /&gt;
as&lt;br /&gt;
BEGIN&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;SELECT TOP 10&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; [Average IO] = (total_logical_reads + total_logical_writes) / qs.execution_count&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;,[Total IO] = (total_logical_reads + total_logical_writes)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;,[Execution count] = qs.execution_count&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;,[Individual Query] = SUBSTRING (qt.text,qs.statement_start_offset/2,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt; (CASE WHEN qs.statement_end_offset = -1&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;THEN LEN(CONVERT(NVARCHAR(MAX), qt.text)) * 2&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt; &amp;nbsp;ELSE qs.statement_end_offset END - qs.statement_start_offset)/2)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;,[Parent Query] = qt.text&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;,DatabaseName = DB_NAME(qt.dbid)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;FROM sys.dm_exec_query_stats qs&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as qt&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;ORDER BY [Average IO] DESC;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;SELECT TOP 10&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; [Average CPU used] = total_worker_time / qs.execution_count&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;,[Total CPU used] = total_worker_time&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;,[Execution count] = qs.execution_count&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;,[Individual Query] = SUBSTRING (qt.text,qs.statement_start_offset/2,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt; (CASE WHEN qs.statement_end_offset = -1&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;THEN LEN(CONVERT(NVARCHAR(MAX), qt.text)) * 2&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt; &amp;nbsp;ELSE qs.statement_end_offset END -&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;qs.statement_start_offset)/2)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;,[Parent Query] = qt.text&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;,DatabaseName = DB_NAME(qt.dbid)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;FROM sys.dm_exec_query_stats qs&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as qt&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;ORDER BY [Average CPU used] DESC;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;SELECT TOP 10&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Total Logical Reads] = qs.total_logical_reads,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Last Logical Reads] = qs.last_logical_reads,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Total Logical Writes] = qs.total_logical_writes,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Last Logical Writes] = qs.last_logical_writes,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Execution count] = qs.execution_count,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Individual Query] = SUBSTRING(qt.TEXT, (qs.statement_start_offset/2)+1,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;((CASE qs.statement_end_offset&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;WHEN -1 THEN DATALENGTH(qt.TEXT)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;ELSE qs.statement_end_offset&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;END - qs.statement_start_offset)/2)+1),&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Parent Query] = qt.text,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;DatabaseName = DB_NAME(qt.dbid),&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Total Worker Time] = qs.total_worker_time,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Last Worker Time] = qs.last_worker_time,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Total Elapsed Time Seconds] = qs.total_elapsed_time/1000000 ,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Last Elapsed Time Seconds] = qs.last_elapsed_time/1000000 ,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Last Execution Time] = qs.last_execution_time,&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[Query Plan] = qp.query_plan&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;FROM sys.dm_exec_query_stats qs&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qt&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;ORDER BY qs.total_logical_reads DESC&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;SELECT TOP 10&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;[Total Reads] = SUM(total_logical_reads)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;,[Execution count] = SUM(qs.execution_count)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;,DatabaseName = DB_NAME(qt.dbid)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;FROM sys.dm_exec_query_stats qs&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as qt&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;GROUP BY DB_NAME(qt.dbid)&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;ORDER BY [Total Reads] DESC;&lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-2351284419476517939?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/2351284419476517939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=2351284419476517939' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/2351284419476517939?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/2351284419476517939?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/03/proc-to-show-expensive-queires.html' title='Proc to show expensive queries : sp_expensive_queries'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DEUAR30_eyp7ImA9WhVTFU4.&quot;'><id>tag:blogger.com,1999:blog-12181313.post-3788055703013863905</id><published>2012-02-29T09:24:00.000-08:00</published><updated>2012-02-29T09:24:06.343-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-02-29T09:24:06.343-08:00</app:edited><title>Automate Monitoring SQL Server Error Logs with Email Alerts</title><content type='html'>&lt;a href="http://www.mssqltips.com/sqlservertip/2307/automate-monitoring-sql-server-error-logs-with-email-alerts/?utm_source=dailynewsletter&amp;amp;utm_medium=email&amp;amp;utm_content=headline&amp;amp;utm_campaign=2012111"&gt;Automate Monitoring SQL Server Error Logs with Email Alerts&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12181313-3788055703013863905?l=mssql2000.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.mssqltips.com/sqlservertip/2307/automate-monitoring-sql-server-error-logs-with-email-alerts/?utm_source=dailynewsletter&amp;utm_medium=email&amp;utm_content=headline&amp;utm_campaign=2012111' title='Automate Monitoring SQL Server Error Logs with Email Alerts'/><link rel='replies' type='application/atom+xml' href='http://mssql2000.blogspot.com/feeds/3788055703013863905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12181313&amp;postID=3788055703013863905' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/3788055703013863905?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12181313/posts/default/3788055703013863905?v=2'/><link rel='alternate' type='text/html' href='http://mssql2000.blogspot.com/2012/02/automate-monitoring-sql-server-error.html' title='Automate Monitoring SQL Server Error Logs with Email Alerts'/><author><name>Patrick Alexander</name><uri>https://plus.google.com/102485284935767693811</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-OLCrhSnHD5A/AAAAAAAAAAI/AAAAAAAAKGI/VR0BHZudM70/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry></feed>