<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5206410214044650233</id><updated>2024-11-09T02:39:48.880+11:00</updated><category term="SQL Server 2000"/><category term="sql server 2005"/><category term="sql server 2008"/><category term="Optimization"/><category term="database"/><category term="database property"/><category term="index"/><category term="Maintenance Plans"/><category term="columns"/><category term="included columns"/><category term="master database"/><category term="troubleshooting"/><category term="Recovery model"/><category term="Tables"/><category term="index size"/><category term="largest table"/><category term="query"/><category term="size"/><title type='text'>sqldbafamily</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>34</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-3197436713157473996</id><published>2014-09-17T16:15:00.000+10:00</published><updated>2014-09-17T16:15:24.219+10:00</updated><title type='text'>Shared components are installed in the wrong location when you implement a SQL Server 2012 Failover Cluster installation</title><content type='html'>&lt;b&gt;&lt;i&gt;Issue:&amp;nbsp;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This has been an issue with SQL Server 2008 (http://support.microsoft.com/kb/2028830) and its still occurring in 2012.&lt;br /&gt;
&lt;br /&gt;
If we have shared components installed to any drives other than default C:\ drive, this issue will occur. Also, we wont find this issue unless we fail over to the corrupt node. Then after fail over we will find that the LS is failing and errors clearly indicate that it can&#39;t find Logship.exe file.&lt;br /&gt;
&lt;br /&gt;
Version we had running: SQL Server Standard Edition 2012 + SP1&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Workaround:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
Whenever the node is failed over to the corrupt one, we can modify the LS job to look for the components in C:\ drive&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Resolution:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
We raised this MS support and they had us playing with the Prod system in trying out the solution.&lt;br /&gt;
&lt;br /&gt;
Finally, solution is&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Uninstall all components from problem node&lt;/li&gt;
&lt;li&gt;Install SQL Server 2012 + SP2 via Slipstream&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
I can confirm that this has resolved the issue for us.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Note: We tried using the new method of Slipstreaming with UPDATESOURCE and we did face some issues. Hence we went back and did it the old way (with PCUSOURCE). I am gonna post another article soon on how to slipstream.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;i&gt;MvM&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/3197436713157473996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2014/09/shared-components-are-installed-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/3197436713157473996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/3197436713157473996'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2014/09/shared-components-are-installed-in.html' title='Shared components are installed in the wrong location when you implement a SQL Server 2012 Failover Cluster installation'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-6892695626577970428</id><published>2014-07-08T11:31:00.001+10:00</published><updated>2014-07-08T11:33:14.305+10:00</updated><title type='text'>Error while trying to open ALERTS in SQL Server</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Here below is the error i got while trying to open ALERTS from sql server. The version i had here is SQL 2012.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
TITLE: Microsoft SQL Server Management Studio&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Cannot show requested dialog.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
ADDITIONAL INFORMATION:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Cannot show requested dialog. (SqlMgmt)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Failed to create/initialize Agent Alert dialog. (SqlManagerUI)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Cannot create/initialize Response page. (SqlManagerUI)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
An item with the same key has already been added. (mscorlib)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
BUTTONS:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
OK&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigpdaf0VtGs0Zj4G_is0j45PY0qwzeuaSYO9iw86NjICMtgPB8bn4Aig94-lRN7Mb92es0VFjOrQjRMuSCyoBL65wgQ8dTCH2OahCNhVr0AsAYX0g-F22IdewF5Ks_LcAaePuNJLaauG2a/s1600/Untitled.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigpdaf0VtGs0Zj4G_is0j45PY0qwzeuaSYO9iw86NjICMtgPB8bn4Aig94-lRN7Mb92es0VFjOrQjRMuSCyoBL65wgQ8dTCH2OahCNhVr0AsAYX0g-F22IdewF5Ks_LcAaePuNJLaauG2a/s1600/Untitled.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;b&gt;&lt;u&gt;&lt;i&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;ISSUE&lt;/span&gt;&lt;/i&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;Issue here is that we have Agent Jobs set up with the same name.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20.162017822265625px;&quot;&gt;From the error message, we see this: &lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20.162017822265625px;&quot;&gt;An item with the same key has already been added. (mscorlib)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20.162017822265625px;&quot;&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;It means there are two jobs with the same name. In this situation, SQL Server will prevent all operations on alert.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20.162017822265625px;&quot;&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20.162017822265625px;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;RESOLUTION&lt;/span&gt;&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 14px; line-height: 20.162017822265625px;&quot;&gt;We need to find the duplicate jobs and either rename them or delete them if not required. This should fix the issue.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;b&gt;&lt;u&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;b&gt;&lt;i&gt;MvM&lt;/i&gt;&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/6892695626577970428/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2014/07/error-while-trying-to-open-alerts-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/6892695626577970428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/6892695626577970428'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2014/07/error-while-trying-to-open-alerts-in.html' title='Error while trying to open ALERTS in SQL Server'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigpdaf0VtGs0Zj4G_is0j45PY0qwzeuaSYO9iw86NjICMtgPB8bn4Aig94-lRN7Mb92es0VFjOrQjRMuSCyoBL65wgQ8dTCH2OahCNhVr0AsAYX0g-F22IdewF5Ks_LcAaePuNJLaauG2a/s72-c/Untitled.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-1704347112347731742</id><published>2013-07-17T11:52:00.002+10:00</published><updated>2013-07-17T11:52:40.797+10:00</updated><title type='text'>Cumulative Update #12 for SQL Server 2008 SP3</title><content type='html'>&lt;a href=&quot;http://blogs.msdn.com/b/sqlreleaseservices/archive/2013/07/16/cumulative-update-12-for-sql-server-2008-sp3.aspx&quot;&gt;http://blogs.msdn.com/b/sqlreleaseservices/archive/2013/07/16/cumulative-update-12-for-sql-server-2008-sp3.aspx&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot;&gt;The 12&lt;/span&gt;&lt;sup style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; line-height: 19.5px;&quot;&gt;th&lt;/sup&gt;&lt;span style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot;&gt;&amp;nbsp;cumulative&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot;&gt;update release for SQL Server 2008 Service Pack 3 is now available for download&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot;&gt;at the Microsoft Support site. Cumulative Update 12 contains all the hotfixes&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot;&gt;released since the initial relea&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot;&gt;se of SQL Server 2008 SP3.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px;&quot;&gt;&lt;b&gt;&lt;i&gt;MvM&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/1704347112347731742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2013/07/cumulative-update-12-for-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/1704347112347731742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/1704347112347731742'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2013/07/cumulative-update-12-for-sql-server.html' title='Cumulative Update #12 for SQL Server 2008 SP3'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-165308080489618363</id><published>2013-07-17T11:50:00.005+10:00</published><updated>2013-07-17T11:50:49.205+10:00</updated><title type='text'>Cumulative Update #5 for SQL Server 2012 SP1</title><content type='html'>&lt;div style=&quot;color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px; margin-top: 12px;&quot;&gt;
&lt;a href=&quot;http://blogs.msdn.com/b/sqlreleaseservices/archive/2013/07/16/cumulative-update-5-for-sql-server-2012-sp1.aspx&quot;&gt;http://blogs.msdn.com/b/sqlreleaseservices/archive/2013/07/16/cumulative-update-5-for-sql-server-2012-sp1.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px; margin-top: 12px;&quot;&gt;
The 5&lt;sup&gt;th&lt;/sup&gt;&amp;nbsp;cumulative update release for SQL Server 2012 SP1 is now available for download at the Microsoft Support site.&lt;/div&gt;
&lt;div style=&quot;color: #424242; font-family: &#39;Segoe UI&#39;, &#39;Lucida Grande&#39;, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.5px; margin-top: 12px;&quot;&gt;
&lt;b&gt;&lt;i&gt;MvM&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/165308080489618363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2013/07/cumulative-update-5-for-sql-server-2012.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/165308080489618363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/165308080489618363'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2013/07/cumulative-update-5-for-sql-server-2012.html' title='Cumulative Update #5 for SQL Server 2012 SP1'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-9025277388556245472</id><published>2012-11-29T16:13:00.000+11:00</published><updated>2012-11-29T16:13:42.360+11:00</updated><title type='text'>Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward</title><content type='html'>&lt;span style=&quot;color: red;&quot;&gt;Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;I restored a Full backup and then tried restoring a transaction log with NORECOVERY and thats how i obtained this error. And that exactly is the issue.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Inorder for trn logs to be restored, full backup restore should have been done with NORECOVERY.&lt;br /&gt;
&lt;br /&gt;
Perform it that way and restores work like charm.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;MvM&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/9025277388556245472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/11/error-msg-3117-level-16-state-4-log-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/9025277388556245472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/9025277388556245472'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/11/error-msg-3117-level-16-state-4-log-or.html' title='Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-4080730299719471519</id><published>2012-11-15T15:46:00.000+11:00</published><updated>2012-11-15T15:47:39.952+11:00</updated><title type='text'>Cannot connect to .Login failed for user &#39;&#39;. Reason: Server is in script upgrade mode. Only administrator can connect at this time.</title><content type='html'>TITLE: Connect to Server&lt;br /&gt;
------------------------------&lt;br /&gt;
Cannot connect to MYINSTANCE.&lt;br /&gt;
------------------------------&lt;br /&gt;
ADDITIONAL INFORMATION:&lt;br /&gt;
Login failed for user &#39;MY_LOGIN&#39;. Reason: Server is in script upgrade mode. Only administrator can connect at this time.&lt;br /&gt;
&lt;br /&gt;
Error 18401&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is something which I faced when I was trying to connect to my SQL Server instance, just after applying SQL Server 2008 R2 SP2+CU2. I was a little puzzled as this was the first time when I faced this issue.&lt;br /&gt;
&lt;br /&gt;
Just to let you know, this isnt a big deal. This has already been reported as a BUG.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://connect.microsoft.com/SQLServer/feedback/details/416860/error-18401-after-starting-service-after-successfull-sp1-install&quot;&gt;https://connect.microsoft.com/SQLServer/feedback/details/416860/error-18401-after-starting-service-after-successfull-sp1-install&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I havent had done anything specific other than the normal run for the patch installation.&lt;br /&gt;
&lt;br /&gt;
1. Apply SP2&lt;br /&gt;
2. Reboot&lt;br /&gt;
3. Apply CU2.&lt;br /&gt;
4. Check SSMS&lt;br /&gt;
&lt;br /&gt;
ISSUE &amp;amp; CAUSE:&lt;br /&gt;
***************&lt;br /&gt;
SP&amp;nbsp;installation completes successfully but some of the scripts (Ex: sqlagent100_msdb_upgrade.sql) in the SP will be applied only after the SQL Server service starts the next time. These scripts were getting applied to the instance and I was trying to connect to the instance during that time.&amp;nbsp;This caused&amp;nbsp;the error mesage to pop up.&lt;br /&gt;
&lt;br /&gt;
RESOLUTION:&lt;br /&gt;
*************&lt;br /&gt;
Patience is the only solution to this, as you have to wait some time for the scripts to&amp;nbsp;be applied completely and after this has been done, any one&amp;nbsp;whos authorized to connect to the DB will be allowed to connect as normal.&lt;br /&gt;
&lt;br /&gt;
I did the same and that worked !!!&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;MvM&lt;/em&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/4080730299719471519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/11/cannot-connect-to-login-failed-for-user.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/4080730299719471519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/4080730299719471519'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/11/cannot-connect-to-login-failed-for-user.html' title='Cannot connect to .Login failed for user &#39;&#39;. Reason: Server is in script upgrade mode. Only administrator can connect at this time.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-2086058880989458024</id><published>2012-10-25T10:21:00.001+11:00</published><updated>2012-10-25T10:21:38.794+11:00</updated><title type='text'>Files Are Not Deleted From Recycler Folder</title><content type='html'>I have encountered an issue today where the drive was filling up. I deleted some old backups from the drive and still there were some hidden files which were taking up space. when i checked, it was the RECYCLER folder. This was keeping some of the very old deleted files, which i had to delete manually and release space to the drive. Here below is the link to the MS site about this and how to delete the contents of this folder.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://support.microsoft.com/kb/229041&quot;&gt;http://support.microsoft.com/kb/229041&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
To resolve this issue, delete the files from an MS-DOS prompt. To do this, follow these steps: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.Click Start, click Run, type cmd.exe in the Open box, and then click OK.&lt;br /&gt;
&lt;br /&gt;
2.Change to the drive and folder where you deleted the files. For example if you deleted a file from the C:\Windows folder, type cd\windows at the C: prompt, and then press ENTER. &lt;br /&gt;
&lt;br /&gt;
3.From that folder type cd recycler, and then press ENTER.&lt;br /&gt;
&lt;br /&gt;
4.From the Recycler folder type dir, and then press ENTER. You may see some UserSID folders where SID is the security ID for each user who deleted files in that folder.&lt;br /&gt;
&lt;br /&gt;
5.Type cd userSID, and then press ENTER.&lt;br /&gt;
&lt;br /&gt;
6.Type del *.*, and then press ENTER. If you receive an error message that indicates some files are open, quit all the programs running on your computer.&lt;br /&gt;
&lt;br /&gt;
7.Type cd.., press ENTER, and then repeat steps 5-7 for each folder in the Recycler folder.&lt;br /&gt;
&lt;br /&gt;
8.Type exit, and then press ENTER.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;MvM&lt;/em&gt;&lt;/strong&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/2086058880989458024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/10/files-are-not-deleted-from-recycler.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/2086058880989458024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/2086058880989458024'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/10/files-are-not-deleted-from-recycler.html' title='Files Are Not Deleted From Recycler Folder'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-1030494329952806005</id><published>2012-10-18T12:17:00.004+11:00</published><updated>2012-10-18T12:17:36.633+11:00</updated><title type='text'>Cumulative update package 3 for SQL Server 2008 R2 Service Pack 2 </title><content type='html'>&lt;br /&gt;
Build 10.50.4266.0 (cumulative update)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This cumulative update package was released on October 15, 2012.&lt;br /&gt;
&lt;br /&gt;
The parent build of this build is 10.50.4263.0. &lt;br /&gt;
&lt;br /&gt;
For more information about this build, click the following article number to view the article in the Microsoft Knowledge Base:&lt;br /&gt;
&lt;br /&gt;
2754552 &lt;a href=&quot;http://support.microsoft.com/kb/2754552&quot;&gt;http://support.microsoft.com/kb/2754552&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Cumulative update package 3 for SQL Server 2008 R2 Service Pack 2 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/1030494329952806005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/10/cumulative-update-package-3-for-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/1030494329952806005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/1030494329952806005'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/10/cumulative-update-package-3-for-sql.html' title='Cumulative update package 3 for SQL Server 2008 R2 Service Pack 2 '/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-9020128340135646006</id><published>2012-10-18T11:35:00.004+11:00</published><updated>2012-10-18T11:35:54.506+11:00</updated><title type='text'>SQL Server 2008 R2 SP2 CU2 fails - sqlagtctr.dll</title><content type='html'>I have faced isssues with few systems now regarding the DLL &#39;sqlagtctr.dll&#39;&lt;br /&gt;
&lt;br /&gt;
====== From C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Final result: The patch installer has failed to update the following instance: MSSQLSERVER. To determine the reason for failure, review the log files.&lt;br /&gt;
&lt;br /&gt;
MSSQL10_50.MYSERVER-sqlagtctr.dll. ---&amp;gt; Microsoft.SqlServer.Configuration.Sco.ScoException: The process cannot access the file &#39;C:\Windows\system32\perf-MSSQL10_50.MYSERVER-sqlagtctr.dll&#39; because it is being used by another process. ---&amp;gt; System.IO.IOException: The process cannot access the file &#39;C:\Windows\system32\perf-MSSQL10_50.MYSERVER-sqlagtctr.dll&#39; because it is being used by another process.&lt;br /&gt;
&lt;br /&gt;
MSSQL10_50.MYSERVER-sqlagtctr.dll. ---&amp;gt; Microsoft.SqlServer.Configuration.Sco.ScoException: The process cannot access the file &#39;C:\Windows\SysWOW64\perf-MSSQL10_50.MYSERVER-sqlagtctr.dll&#39; because it is being used by another process. ---&amp;gt; System.IO.IOException: The process cannot access the file &#39;C:\Windows\SysWOW64\perf-MSSQL10_50.MYSERVER-sqlagtctr.dll&#39; because it is being used by another process.&lt;br /&gt;
&lt;br /&gt;
With workarounds from Microsoft sites, I have renamed these DLL’s and have completed the upgrade successfully. 
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://blogs.msdn.com/b/karthick_pk/archive/2012/07/16/the-process-cannot-access-the-file-c-windows-system32-perf-mssql10-50-mssqlserver-sqlagtctr-dll-because-it-is-being-used-by-another-process.aspx&quot;&gt;http://blogs.msdn.com/b/karthick_pk/archive/2012/07/16/the-process-cannot-access-the-file-c-windows-system32-perf-mssql10-50-mssqlserver-sqlagtctr-dll-because-it-is-being-used-by-another-process.aspx&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://social.msdn.microsoft.com/Forums/en-US/sqlsetupandupgrade/thread/06fc5c42-9d5d-4331-a4b9-210559411eee&quot;&gt;http://social.msdn.microsoft.com/Forums/en-US/sqlsetupandupgrade/thread/06fc5c42-9d5d-4331-a4b9-210559411eee&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://connect.microsoft.com/SQLServer/feedback/details/576412/-the-process-cannot-access-the-file-c-windows-syswow64-perf-mssql10-50-mssqlserver-sqlagtctr-dll-because-it-is-being-used-by-another-process&quot;&gt;https://connect.microsoft.com/SQLServer/feedback/details/576412/-the-process-cannot-access-the-file-c-windows-syswow64-perf-mssql10-50-mssqlserver-sqlagtctr-dll-because-it-is-being-used-by-another-process&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
A similar issue to the one I mentioned above, that might occur with upgrading of cluster resources during SP2 install. (http://msdn.microsoft.com/en-US/library/hh995349(v=sql.15).aspx)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2.2 Setup Might Fail if SQAGTRES.dll Is Locked by Another Process&lt;br /&gt;
&lt;br /&gt;
Issue: A SQL Server setup operation might fail with this error: Upgrading of cluster resource C:\Program Files\Microsoft SQL Server\MSSQL10_50.&lt;instance name=&quot;name&quot;&gt;\MSSQL\Binn\SQAGTRES.DLL on machine &lt;computer name=&quot;name&quot;&gt; failed with Win32Exception. Please look at inner exception for details. The root cause is that C:\Windows\system32\SQAGTRES.DLL is locked by another process and Setup was not able to update it.&lt;/computer&gt;&lt;/instance&gt;&lt;br /&gt;
&lt;br /&gt;
Workaround: Rename C:\Windows\system32\SQAGTRES.DLL to a temporary name such as C:\Windows\system32\SQAGTRES_old.DLL, and then select the Retry option on the setup error message. That will allow Setup to continue. After a reboot, you can delete the temporary file C:\Windows\system32\SQAGTRES_old.DLL.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;MvM&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/9020128340135646006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/10/sql-server-2008-r2-sp2-cu2-fails.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/9020128340135646006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/9020128340135646006'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/10/sql-server-2008-r2-sp2-cu2-fails.html' title='SQL Server 2008 R2 SP2 CU2 fails - sqlagtctr.dll'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-6806255456308665257</id><published>2012-08-09T13:41:00.000+10:00</published><updated>2012-08-09T13:41:38.062+10:00</updated><title type='text'>Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset &quot;DBSCHEMA_TABLES_INFO&quot; for OLE DB provider &quot;SQLNCLI10&quot; for linked server &quot; &quot;. The provider supports the interface, but returns a failure code when it is used.</title><content type='html'>I was trying to run a job from a SQL Server 2008 R2 64bit Test machine which connects to a 32bit SQL Server 2000 Production machine through a Linked Server. When I tried running the query after creating the Linked Server, it throwed up the following error message.&lt;br /&gt;
&lt;br /&gt;
&lt;address&gt;OLE DB provider &quot;SQLNCLI10&quot; for linked server &quot;FOCUS&quot; returned message &quot;Unspecified error&quot;.&lt;/address&gt;&lt;address&gt;OLE DB provider &quot;SQLNCLI10&quot; for linked server &quot;FOCUS&quot; returned message &quot;The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator.&quot;.&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;Msg 7311, Level 16, State 2, Line 1&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;Cannot obtain the schema rowset &quot;DBSCHEMA_TABLES_INFO&quot; for OLE DB provider &quot;SQLNCLI10&quot; for linked server &quot;FOCUS&quot;. The provider supports the interface, but returns a failure code when it is used.&lt;/span&gt;&lt;/address&gt;Since I had ran this query directly on PROD, I was pretty sure that the query works fine.  Then I found the link from MS site while googling.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://support.microsoft.com/kb/906954&quot;&gt;http://support.microsoft.com/kb/906954&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Then I found that it basically needs a stored procedure (&lt;em&gt;&lt;strong&gt;sp_tables_info_rowset_64&lt;/strong&gt;&lt;/em&gt;) to fix the issue between 32bit and 64bit. The complete procedure is available in multiple sites. But the fix only requires few lines of it. The code is listed below.&lt;br /&gt;
&lt;br /&gt;
&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;create procedure&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #800000;&quot;&gt;sp_tables_info_rowset_64&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@table_name &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;sysname&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@table_schema &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;sysname &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;null,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@table_type &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;nvarchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;255&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;as&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;declare&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @Result &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;int &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;set&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @Result &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;exec&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @Result &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #800000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #800000;&quot;&gt;sp_tables_info_rowset &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;@table_name&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @table_schema&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @table_type&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;go&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;strong&gt;MvM&lt;/strong&gt;&lt;/address&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/6806255456308665257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/08/msg-7311-level-16-state-2-line-1-cannot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/6806255456308665257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/6806255456308665257'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/08/msg-7311-level-16-state-2-line-1-cannot.html' title='Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset &quot;DBSCHEMA_TABLES_INFO&quot; for OLE DB provider &quot;SQLNCLI10&quot; for linked server &quot; &quot;. The provider supports the interface, but returns a failure code when it is used.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-8341200976832113687</id><published>2012-08-09T11:14:00.001+10:00</published><updated>2012-08-09T11:14:48.564+10:00</updated><title type='text'>Restore nightly backups script</title><content type='html'>I am used to getting requests from users to restore Test databases with that of PROD. This could be ad-hoc or on schedule. The below script takes inputs as DB Name, Prod Backup location and backupfile name and restores the Test db. I have made modifications to suit my requirement.&lt;br /&gt;
&lt;br /&gt;
&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;----------------------------------------------------------------------------------------&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- Restore database from a backup file&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- NOTE: If the database gets locked in Single user mode, execute&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- the below command on it and it will restore the Multiuser mode:&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- ALTER DATABASE yourdatabasename SET MULTI_USER&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- Modify the @databaseName, @restoreDirectory &amp;amp; @backupFileName as per your requirement.&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;---------------------------------------------------------------------------------------&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;USE &lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;master&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;GO&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- Declare the variables&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;DECLARE &lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;@backupFileName &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;varchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@restoreDirectory &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;varchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@databaseDataFilename &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;varchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@databaseLogFilename &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;varchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@databaseDataFile &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;varchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@databaseLogFile &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;varchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@databaseName &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;varchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@execSql &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;nvarchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- Set the name of the database to restore&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;SET&lt;/span&gt; &lt;span style=&quot;font-size: small;&quot;&gt;@databaseName &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;YOUR_DATABASE_NAME&#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- Set the path to the directory containing the database backup file.&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- IMPORTANT:: Make sure there is a \ character at the end of your directory path as below;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;SET &lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;@restoreDirectory &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;LOCATION OF BACKUPFILE&#39; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;-- such as &#39;\\NETWORK\BKUP\DB\&#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- Create the backup file name based on the restore directory, the database name and today&#39;s date &amp;amp; time.&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- The formatting has been done as per my backup file requirement.&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;SET&lt;/span&gt; &lt;span style=&quot;font-size: small;&quot;&gt;@backupFileName &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @restoreDirectory &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseName &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;_backup_&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;convert&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;varchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;getdate&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; 112&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;.bak&#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;font-size: small;&quot;&gt;@backupFileName&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- Get the data file and its path&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;font-size: small;&quot;&gt;@databaseDataFile &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;RTRIM&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;[Name]&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;),&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@databaseDataFilename &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;RTRIM&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;[Filename]&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;master&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;sysaltfiles &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;AS &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; files&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;INNER &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;JOIN &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;master&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;sysfilegroups &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; groups&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; files&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;groupID &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; groups&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;groupID&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;WHERE&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;dbid &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;(&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;  SELECT &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;dbid &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;  FROM &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;master&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;sysdatabases&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;  WHERE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; [Name] &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseName&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- Get the log file and its path&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;@databaseLogFile &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;rtrim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;[Name]&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;),&lt;/span&gt;&lt;/address&gt;&lt;address&gt;@databaseLogFilename &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;rtrim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;[Filename]&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;master&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;sysaltfiles &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; files&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;WHERE&lt;/span&gt; dbid &lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;(&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt; SELECT &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;dbid&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt; FROM &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;master&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;sysdatabases&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt; WHERE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; [Name] &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseName&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #808080;&quot;&gt;AND&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;font-size: small;&quot;&gt;groupID &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; 0&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;Killing active connections to the &quot;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseName &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+ &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&quot; database&#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- Create the sql to kill the active database connections&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;SET&lt;/span&gt; &lt;span style=&quot;font-size: small;&quot;&gt;@execSql &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;@execSql &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @execSql &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;kill &#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;convert&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;char&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; spid&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+ &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;master&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #008000;&quot;&gt;sysprocesses&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;WHERE&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;db_name&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;dbid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseName&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #808080;&quot;&gt;AND&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff;&quot;&gt;dbid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; 0 &lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #808080;&quot;&gt;AND&lt;/span&gt; &lt;span style=&quot;font-size: small;&quot;&gt;spid &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&amp;lt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff00ff;&quot;&gt;@@spid&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;-- EXEC (@execSql)&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;Restoring &quot;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseName &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&quot; database from &quot;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @backupFileName &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+ &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&quot; with &#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39; DATA file &quot;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseDataFile &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&quot; located at &quot;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseDataFilename &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&quot;&#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39; LOG file &quot;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseLogFile &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&quot; located at &quot;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseLogFilename &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+ &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&quot;&#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;SET&lt;/span&gt; &lt;span style=&quot;font-size: small;&quot;&gt;@execSql &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;restore database&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;[&#39;&lt;/span&gt; &lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseName &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+ &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;]&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;from disk = &#39;&#39;&#39; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @backupFileName &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+ &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&#39;&#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;with&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;file = 1,&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;        move &#39;&#39;&#39; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseDataFile &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&#39;&#39; to &#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&#39;&#39;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseDataFilename &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+ &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&#39;&#39;,&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;move &#39;&#39;&#39; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseLogFile &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&#39;&#39; to &#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&#39;&#39;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; @databaseLogFilename &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;&lt;span style=&quot;font-size: small; color: #808080;&quot;&gt;+ &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #ff0000;&quot;&gt;&#39;&#39;&#39;,&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;norewind,&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;        nounload,&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;        replace&#39;&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;font-size: small;&quot;&gt;@execsql&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;EXEC&lt;/span&gt; &lt;span style=&quot;color: #800000;&quot;&gt;sp_executesql&lt;/span&gt; @execSql&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;span style=&quot;color: #008000;&quot;&gt;---------------End of Restore script---------------------------------------&lt;/span&gt;&lt;/address&gt;&lt;address&gt;&lt;/address&gt;&lt;address&gt;&lt;strong&gt;MvM&lt;/strong&gt;&lt;/address&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/8341200976832113687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/08/restore-nightly-backups-script.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/8341200976832113687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/8341200976832113687'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/08/restore-nightly-backups-script.html' title='Restore nightly backups script'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-7262809654632823919</id><published>2012-08-02T21:37:00.001+10:00</published><updated>2012-08-02T21:37:00.412+10:00</updated><title type='text'>Biggest Tables in a database - SQL Server 2000</title><content type='html'>&lt;address&gt;
The below mentioned script is only for SQL Server 2000 and I already have posted a simpler script to find the same from SQL 2005/2008.&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;@id &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;@type &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;character&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;@pages &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;@dbname &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;sysname&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;@dbsize &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;dec&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;@bytesperpage &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;dec&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;@pagesperMB &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;dec&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;create&lt;/span&gt; &lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;table&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; #spt_space&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
( &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;objid &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;null, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;rows &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;null, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;reserved &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;dec&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;null,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
data &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;dec&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;null, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;indexp &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;dec&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;null, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;unused &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;dec&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;)&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt; &lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;nocount &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;on&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: green;&quot;&gt;-- Create a cursor to loop through the user tables&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare &lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;c_tables &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;cursor &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;for&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;select&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;id&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;sysobjects&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;xtype &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;U&#39;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;open&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;c_tables&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;fetch&lt;/span&gt; &lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;next &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;from&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; c_tables &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;into&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;@id&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;@@fetch_status&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 0&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;begin&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;/* Code from sp_spaceused */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;insert &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;into&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; #spt_space&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;objid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; reserved&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;select &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;objid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;reserved&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;from &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;sysindexes &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; indid &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 255&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;and&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; id &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @pages &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;dpages&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;from &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;sysindexes &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; indid &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;and&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; id &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @pages &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @pages &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;isnull&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;used&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;from &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;sysindexes &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; indid &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 255 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;and&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; id &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;update&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; #spt_space&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;set&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; data &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @pages&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;where &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;objid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;/* index: sum(used) where indid in (0, 1, 255) - data */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;update&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; #spt_space &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;set&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; indexp &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;used&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;from &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;sysindexes &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; indid &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;in&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 255&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;and&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; id &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; data&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;where &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;objid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;/* unused: sum(reserved) - sum(used) where indid in (0, 1, 255) */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;update&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; #spt_space &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;set&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; unused &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; reserved&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;used&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;from &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;sysindexes &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; indid &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;in&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 255&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;and&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; id &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;where &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;objid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;update&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; #spt_space &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;set &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;rows&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;rows &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;from &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;sysindexes&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; i &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;indid &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 2 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;and&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;id &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;and &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;objid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;fetch &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;next &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;from&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; c_tables &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;into&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @id&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;end&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
select &lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;top&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 25&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
Table_Name &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;select &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;left (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;25&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;from &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;sysobjects &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; id &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;objid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;rows &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;convert&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;char&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;), &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;rows&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
reserved_KB &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;ltrim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;str&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;reserved &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;low &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1024.&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;KB&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
data_KB &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;ltrim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;str&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;data &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;low &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1024.&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;KB&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
index_size_KB &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;ltrim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;str&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;indexp &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;low &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1024.&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;KB&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
unused_KB &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;ltrim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;str&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;unused &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;low &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1024.&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;KB&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;#spt_space&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;master&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;spt_values d&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;number &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
and &lt;span style=&quot;font-size: x-small;&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;type&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;E&#39;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;order&lt;/span&gt; &lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;by&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; reserved &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;desc&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;drop&lt;/span&gt; &lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;table&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; #spt_space&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;close&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;c_tables&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;deallocate&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;c_tables&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
 &lt;/address&gt;
&lt;address&gt;
&lt;strong&gt;MvM&lt;/strong&gt;&lt;/address&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/7262809654632823919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/08/biggest-tables-in-database-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/7262809654632823919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/7262809654632823919'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/08/biggest-tables-in-database-sql-server.html' title='Biggest Tables in a database - SQL Server 2000'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-8441967618369304806</id><published>2012-08-02T21:36:00.000+10:00</published><updated>2012-08-02T21:37:39.278+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="columns"/><category scheme="http://www.blogger.com/atom/ns#" term="database"/><category scheme="http://www.blogger.com/atom/ns#" term="database property"/><category scheme="http://www.blogger.com/atom/ns#" term="included columns"/><category scheme="http://www.blogger.com/atom/ns#" term="index"/><category scheme="http://www.blogger.com/atom/ns#" term="Maintenance Plans"/><category scheme="http://www.blogger.com/atom/ns#" term="master database"/><category scheme="http://www.blogger.com/atom/ns#" term="Optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2000"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2005"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="troubleshooting"/><title type='text'>Database Restore History</title><content type='html'>&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;USE&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;msdb&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Select&lt;/span&gt; &lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;top&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 20&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
DBRestored&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; destination_database_name&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
SourceFile&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; physical_name&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
RestoreDate&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; restore_date&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;RestoreHistory h&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: grey;&quot;&gt;inner&lt;/span&gt; &lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;join&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; BackupSet b&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;on&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;backup_set_id &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;backup_set_id&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: grey;&quot;&gt;inner&lt;/span&gt; &lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;join&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; BackupFile f&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;on&lt;/span&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;backup_set_id &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;backup_set_id&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;order&lt;/span&gt; &lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;by&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; RestoreDate &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;desc&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/address&gt;
&lt;strong&gt;MvM&lt;/strong&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/8441967618369304806/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/08/database-restore-history.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/8441967618369304806'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/8441967618369304806'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/08/database-restore-history.html' title='Database Restore History'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-5440905814397627022</id><published>2012-07-23T13:24:00.001+10:00</published><updated>2012-07-23T13:27:23.608+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="database"/><category scheme="http://www.blogger.com/atom/ns#" term="index"/><category scheme="http://www.blogger.com/atom/ns#" term="index size"/><category scheme="http://www.blogger.com/atom/ns#" term="size"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2000"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2005"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2008"/><title type='text'>List Indexes and their size</title><content type='html'>&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;SELECT&lt;/span&gt; OBJECT_NAME&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;OBJECT_ID&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; TableName&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;i&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;name &lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; IndexName&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;index_id &lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; IndexID&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;(&lt;span style=&quot;font-size:100%;&quot;&gt;8 &lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;SUM&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;used_pages&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;))/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;1024 &lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;AS &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#ff0000;&quot;&gt;&#39;Indexsize(MB)&#39;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;indexes &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; i&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;JOIN &lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;partitions &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; p &lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;OBJECT_ID&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;OBJECT_ID &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;index_id &lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;index_id&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;JOIN &lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#008000;&quot;&gt;allocation_units &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;container_id &lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;partition_id&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;GROUP&lt;/span&gt; &lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;BY&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;OBJECT_ID&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;index_id&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;name&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ORDER&lt;/span&gt; &lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#0000ff;&quot;&gt;BY &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;OBJECT_NAME&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#ff00ff;&quot;&gt;OBJECT_ID&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;), &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:100%;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;index_id&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;&lt;strong&gt;MvM&lt;/strong&gt;&lt;/address&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/5440905814397627022/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/list-indexes-and-their-size.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/5440905814397627022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/5440905814397627022'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/list-indexes-and-their-size.html' title='List Indexes and their size'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-1627435513853806353</id><published>2012-07-23T13:22:00.001+10:00</published><updated>2012-07-23T13:24:33.589+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="columns"/><category scheme="http://www.blogger.com/atom/ns#" term="database"/><category scheme="http://www.blogger.com/atom/ns#" term="included columns"/><category scheme="http://www.blogger.com/atom/ns#" term="index"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2000"/><title type='text'>List all indexes &amp; their included columns in a database</title><content type='html'>&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;SELECT&lt;/span&gt; &#39;[&#39;+Sch.name+&#39;].[&#39;+ Tab.[name]+&#39;]&#39; AS TableName,&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Ind.[name] AS IndexName,&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#ff00ff;&quot;&gt;SUBSTRING&lt;/span&gt; ((SELECT&#39;, &#39;+ AC.name&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;FROM&lt;/span&gt; sys.[tables] AS T&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;INNER&lt;/span&gt; JOIN sys.[indexes] I ON T.[object_id] = I.[object_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;INNER&lt;/span&gt; JOIN sys.[index_columns] IC ON I.[object_id] = IC.[object_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;AND&lt;/span&gt; I.[index_id] = IC.[index_id] &lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;INNER&lt;/span&gt; JOIN sys.[all_columns] AC ON T.[object_id] = AC.[object_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;AND&lt;/span&gt; IC.[column_id] = AC.[column_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;WHERE&lt;/span&gt; Ind.[object_id] = I.[object_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;AND&lt;/span&gt; Ind.index_id = I.index_id AND IC.is_included_column = 0&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ORDER&lt;/span&gt; BY IC.key_ordinal&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;FOR&lt;/span&gt; XML PATH(&#39;&#39;)), 2, 8000) AS KeyCols,&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#ff00ff;&quot;&gt;SUBSTRING&lt;/span&gt; ((SELECT&#39;, &#39;+ AC.name&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;FROM&lt;/span&gt; sys.[tables] AS T&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;INNER&lt;/span&gt; JOIN sys.[indexes] I ON T.[object_id] = I.[object_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;INNER&lt;/span&gt; JOIN sys.[index_columns] IC ON I.[object_id] = IC.[object_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;AND&lt;/span&gt; I.[index_id] = IC.[index_id] &lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;INNER&lt;/span&gt; JOIN sys.[all_columns] AC ON T.[object_id] = AC.[object_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;AND&lt;/span&gt; IC.[column_id] = AC.[column_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;WHERE&lt;/span&gt; Ind.[object_id] = I.[object_id] AND Ind.index_id = I.index_id&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;AND&lt;/span&gt; IC.is_included_column = 1&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ORDER&lt;/span&gt; BY IC.key_ordinal&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;FOR XML PATH(&lt;span style=&quot;color:#ff0000;&quot;&gt;&#39;&#39;&lt;/span&gt;)), 2, 8000) AS IncludeCols&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;FROM&lt;/span&gt; sys.[indexes] Ind&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;INNER&lt;/span&gt; JOIN sys.[tables] AS Tab ON Tab.[object_id] = Ind.[object_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#808080;&quot;&gt;INNER&lt;/span&gt; JOIN sys.[schemas] AS Sch ON Sch.[schema_id] = Tab.[schema_id]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ORDER&lt;/span&gt; BY TableName&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;strong&gt;MvM&lt;/strong&gt;&lt;/address&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/1627435513853806353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/list-all-indexes-their-included-columns.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/1627435513853806353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/1627435513853806353'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/list-all-indexes-their-included-columns.html' title='List all indexes &amp; their included columns in a database'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-1600623393732240301</id><published>2012-07-23T13:21:00.000+10:00</published><updated>2012-07-23T13:22:20.716+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="database property"/><category scheme="http://www.blogger.com/atom/ns#" term="largest table"/><category scheme="http://www.blogger.com/atom/ns#" term="query"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2000"/><category scheme="http://www.blogger.com/atom/ns#" term="Tables"/><title type='text'>List larger tables in a database</title><content type='html'>I have tried this query only on sql 2008. This will extract all tables with number of rows, reserved,data,index and unused space in MB.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;select&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;name &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;object_schema_name&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;object_id&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff0000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff0000;&quot;&gt;&#39;.&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;object_name&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;object_id&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;rows&lt;/span&gt; &lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;case &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;when&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; index_id &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; 2 &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;then&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; row_count &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; 0 &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;reserved_MB &lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;reserved_page_count&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;)/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;1024&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;data_MB &lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;case &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;when&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; index_id&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;2 &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;then&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; in_row_data_page_count &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; lob_used_page_count &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; row_overflow_used_page_count &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; lob_used_page_count &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; row_overflow_used_page_count &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;)/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;1024&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;index_MB &lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;*(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;used_page_count&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;)-&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;case &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;when&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; index_id&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;2 &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;then&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; in_row_data_page_count &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; lob_used_page_count &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; row_overflow_used_page_count &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; lob_used_page_count &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; row_overflow_used_page_count &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;))/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;1024&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;unused_kb &lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;reserved_page_count&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;used_page_count&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sys.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;dm_db_partition_stats&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;where&lt;/span&gt; &lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;object_id&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; 1024&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;group&lt;/span&gt; &lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;by &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;object_id&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;order&lt;/span&gt; &lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;by &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;rows &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;desc;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;strong&gt;MvM&lt;/strong&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/1600623393732240301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/list-larger-tables-in-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/1600623393732240301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/1600623393732240301'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/list-larger-tables-in-database.html' title='List larger tables in a database'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-7920452030004798478</id><published>2012-07-23T13:19:00.004+10:00</published><updated>2012-07-23T13:21:04.824+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="database property"/><category scheme="http://www.blogger.com/atom/ns#" term="master database"/><category scheme="http://www.blogger.com/atom/ns#" term="Recovery model"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2000"/><title type='text'>List Recovery Model for all databases in SQL Server 2000</title><content type='html'>Two ways I used to find it. But the best one is the first one listed.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#ff00ff;&quot;&gt;DATABASEPROPERTYEX&lt;/span&gt; &lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff0000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff0000;&quot;&gt;&#39;RECOVERY&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; [Recovery Model]&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;master&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sysdatabases&lt;/span&gt;&lt;/address&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;OR&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#800000;&quot;&gt;sp_msforeachdb&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;color:#ff0000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff0000;&quot;&gt;&#39;use [?] select &#39;&#39;?&#39;&#39; as DatabaseName, DATABASEPROPERTYEX(N&#39;&#39;?&#39;&#39;, N&#39;&#39;RECOVERY&#39;&#39;)&#39;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;strong&gt;MvM&lt;/strong&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/7920452030004798478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/list-recovery-model-for-all-databases.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/7920452030004798478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/7920452030004798478'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/list-recovery-model-for-all-databases.html' title='List Recovery Model for all databases in SQL Server 2000'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-7259119052119266194</id><published>2012-07-23T13:19:00.003+10:00</published><updated>2012-07-23T13:19:40.420+10:00</updated><title type='text'>Query to find Database Details in SQL Server 2000</title><content type='html'>&lt;pre&gt;Here&#39;s the SQL Server 2000 version of the query.&lt;br /&gt;Add columns as per your requirement.&lt;/pre&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;select&lt;/span&gt; &lt;span style=&quot;font-size:small;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;SUSER_SNAME&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;owner_sid&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;as &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;Owner,&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;[Total Size MB]&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;cmptlevel&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;from &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;databases&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; MST &lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;inner &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;join &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;name [LOG_DBNAME]&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;CONVERT&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;DECIMAL&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;), &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;CONVERT&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;DECIMAL&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;),(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;size &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;1024&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;&quot;&gt;as [Total Size MB] &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;from &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sysaltfiles&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; A &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;inner &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;join &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;databases&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; B &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;on&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;dbid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; B&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;dbid&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;group &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;by&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;AA &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;on&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; AA&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;[LOG_DBNAME] &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; MST&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;order &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;by &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;owner&lt;span style=&quot;color:#000000;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;strong&gt;MvM&lt;/strong&gt;&lt;/address&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/7259119052119266194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/query-to-find-database-details-in-sql_23.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/7259119052119266194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/7259119052119266194'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/query-to-find-database-details-in-sql_23.html' title='Query to find Database Details in SQL Server 2000'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-4410871331444602836</id><published>2012-07-23T13:19:00.001+10:00</published><updated>2012-07-23T13:31:51.990+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2000"/><title type='text'></title><content type='html'>&lt;pre&gt;Here&#39;s the SQL Server 2000 version of the query.&lt;br /&gt;Add columns as per your requirement.&lt;/pre&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;select&lt;/span&gt; &lt;span style=&quot;font-size:small;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;SUSER_SNAME&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;owner_sid&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;as &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;Owner,&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;[Total Size MB]&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;cmptlevel&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;from &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;databases&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; MST &lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;inner &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;join &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;name [LOG_DBNAME]&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;CONVERT&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;DECIMAL&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;), &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;CONVERT&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;DECIMAL&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;),(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;size &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;1024&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;&quot;&gt;as [Total Size MB] &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;from &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sysaltfiles&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; A &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;inner &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;join &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;databases&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; B &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;on&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;dbid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; B&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;dbid&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;group &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;by&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;AA &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;on&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; AA&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;[LOG_DBNAME] &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; MST&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;order &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;by &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;owner&lt;span style=&quot;color:#000000;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;strong&gt;MvM&lt;/strong&gt;&lt;/address&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/4410871331444602836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/heres-sql-server-2000-version-of-query.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/4410871331444602836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/4410871331444602836'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/heres-sql-server-2000-version-of-query.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-4454469366929333161</id><published>2012-07-23T13:14:00.001+10:00</published><updated>2012-07-23T13:32:24.721+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2005"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2008"/><title type='text'>Query to find Database Details in SQL Server 2005 &amp; 2008</title><content type='html'>Here&#39;s the query which I am using.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;select&lt;/span&gt; Name&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;SUSER_SNAME&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;owner_sid&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;as &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;Owner&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; create_date&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;state_desc&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; [Total Size MB]&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; recovery_model_desc&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;compatibility_level&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; collation_name&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; user_access_desc&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;databases&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; MST &lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;inner &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;join &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;name [LOG_DBNAME]&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;CONVERT&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;DECIMAL&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;), &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;sum&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#ff00ff;&quot;&gt;CONVERT&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;DECIMAL&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;), (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;size &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;1024&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; [Total Size MB] &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;from &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sysaltfiles&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; A &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;inner &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;join &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;&lt;span style=&quot;font-size:small;color:#008000;&quot;&gt;databases&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; B &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;on&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; A&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;dbid&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; B&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;database_id &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;group &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;by&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;AA &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;on&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; AA&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;[LOG_DBNAME] &lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt; MST&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;&lt;span style=&quot;font-size:small;color:#808080;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;&quot;&gt;name &lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;order &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;by &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;&lt;span style=&quot;font-size:small;color:#0000ff;&quot;&gt;owner&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;br /&gt;&lt;address&gt;&lt;/address&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;&quot;&gt;&lt;span style=&quot;font-size:small;&quot;&gt;MvM&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/4454469366929333161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/query-to-find-database-details-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/4454469366929333161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/4454469366929333161'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/query-to-find-database-details-in-sql.html' title='Query to find Database Details in SQL Server 2005 &amp; 2008'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-6814386401585493301</id><published>2012-07-23T13:11:00.000+10:00</published><updated>2012-07-23T13:13:00.546+10:00</updated><title type='text'>Ctrl Alt Del in Remote Desktop</title><content type='html'>I have had this situation so many times that I wanted to press ctrl+alt+del in my remote desktop window and I did and then the local computer responds.&lt;br /&gt;Then, how to do it? Here’s the wonder…Its…&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#3333ff;&quot;&gt;CTRL + ALT + END&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;wow…that sounds bad…but yes, thats the way out…&lt;br /&gt;&lt;br /&gt;MvM</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/6814386401585493301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/ctrl-alt-del-in-remote-desktop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/6814386401585493301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/6814386401585493301'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/ctrl-alt-del-in-remote-desktop.html' title='Ctrl Alt Del in Remote Desktop'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-7053066539860735044</id><published>2012-07-23T13:08:00.002+10:00</published><updated>2012-07-23T13:11:46.647+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Maintenance Plans"/><category scheme="http://www.blogger.com/atom/ns#" term="Optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2000"/><category scheme="http://www.blogger.com/atom/ns#" term="troubleshooting"/><title type='text'>[Microsoft][ODBC SQL Server Driver][SQL Server]DBCC failed because the following SET options have incorrect settings: ‘QUOTED_IDENTIFIER’.</title><content type='html'>I have seen this error lot of times in SQL Server 2000 Maintenance Plans. When job fails, it doesn’t specifically say anything in the ‘Job History’. So, what I used to do is to run the Optimisation code (copied from the job) in Query Analyzer. This will list out each step result for the plan. Thats how I used to see this error message. This specifically appears for the ‘Integrity Checks’ and ‘Optimisation’ Job Plans.&lt;br /&gt;&lt;br /&gt;Here’s how to resolve it.&lt;br /&gt;&lt;br /&gt;Optimizations Job for DB Maintenance Plan ‘DB Maintenance Plan name‘For example, add the parameters to the command as shown in the following command:&lt;br /&gt;EXECUTE master.dbo.xp_sqlmaint N’-S ServerName\InstanceName -PlanID &lt;guid&gt;-WriteHistory -RebldIdx 10 -SupportComputedColumn’&lt;br /&gt;&lt;br /&gt;Integrity Checks Job for DB Maintenance Plan ‘DB Maintenance Plan name‘For example, add the parameters to the command as shown in the following command:&lt;br /&gt;EXECUTE master.dbo.xp_sqlmaint N’-S ServerName\InstanceName -PlanID &lt;guid&gt;-WriteHistory -CkDB -SupportComputedColumn’&lt;br /&gt;&lt;br /&gt;More details and explanations can be found in &lt;a href=&quot;http://support.microsoft.com/kb/902388&quot;&gt;http://support.microsoft.com/kb/902388&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;MvM</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/7053066539860735044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/i-have-seen-this-error-lot-of-times-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/7053066539860735044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/7053066539860735044'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/i-have-seen-this-error-lot-of-times-in.html' title='[Microsoft][ODBC SQL Server Driver][SQL Server]DBCC failed because the following SET options have incorrect settings: ‘QUOTED_IDENTIFIER’.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-4641273529463994681</id><published>2012-07-12T22:18:00.002+10:00</published><updated>2012-07-23T13:32:10.580+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2000"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2005"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2008"/><title type='text'>Change Maintenance Plan Owner to ‘sa’</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
I always had this annoying issue where in I had to update the job owner to ‘sa’ once someone had modified a maintenance plan. This happens when a user logs in with his id (which usually everyone does) and modifies a Maintenance Plan and then saves it. This automatically changes the owner of the job corresponding to it.&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
Below mentioned query is handy when you need to update lot of Maintenance Plans like this.&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: green; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;–SQL 2005&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;UPDATE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;msdb&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;sysdtspackages90&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SET&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;ownersid&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SUSER_SID&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;‘sa’&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;WHERE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;‘MAINT’&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: green; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;–SQL 2008&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;UPDATE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;msdb&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;sysssispackages&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SET&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;ownersid&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SUSER_SID&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;‘sa’&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;WHERE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;‘MAINT’&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: green; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;–**************************&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: black; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;MvM&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/4641273529463994681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/change-maintenance-plan-owner-to-sa.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/4641273529463994681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/4641273529463994681'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/change-maintenance-plan-owner-to-sa.html' title='Change Maintenance Plan Owner to ‘sa’'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-6376321708511481914</id><published>2012-07-12T22:16:00.001+10:00</published><updated>2012-07-23T13:32:10.581+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2000"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2005"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2008"/><title type='text'>Database, Users and their DB Roles (SQL Server 2000 &amp; 2005)</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;strong style=&quot;line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;line-height: inherit; margin: 0px; padding: 0px; text-decoration: underline;&quot;&gt;SQL SERVER 2005&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;DECLARE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;@db_name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SYSNAME&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;@sql&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;DECLARE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;db_cursor&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;CURSOR&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FOR&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;Name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;databases&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;OPEN&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;db_cursor&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FETCH&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;NEXT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;db_cursor&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;@db_name&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;WHILE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;@@FETCH_STATUS&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;BEGIN&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SET&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;@sql&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;‘SELECT ”’&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;@db_name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;+&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;”’ AS [Database],&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: red; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;USER_NAME(role_principal_id) AS [Role], USER_NAME(member_principal_id) AS [User]&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: red; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FROM ‘&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;@db_name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;‘.sys.database_role_members’&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;@sql&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FETCH&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;NEXT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;db_cursor&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;@db_name&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
END&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;CLOSE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;db_cursor&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;DEALLOCATE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;db_cursor&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;line-height: inherit; margin: 0px; padding: 0px; text-decoration: underline;&quot;&gt;&lt;strong style=&quot;line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SQL SERVER 2000&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;DECLARE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;@db_name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SYSNAME&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;@sql&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;DECLARE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;db_cursor&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;CURSOR&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FOR&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;Name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;master&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;..&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;sysdatabases&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;OPEN&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;db_cursor&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FETCH&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;NEXT&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;db_cursor&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;@db_name&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;WHILE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;@@FETCH_STATUS&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;0&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;BEGIN&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SET&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;@sql&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;‘SELECT ”’&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;@db_name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;+&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;”’ AS [Database],&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: red; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;USER_NAME(memberuid) AS [Role],&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;USER_NAME(groupuid) AS [User]&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: red; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FROM sysmembers’&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;EXEC&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;@sql&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FETCH&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;NEXT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;db_cursor&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;@db_name&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;END&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;CLOSE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;db_cursor&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;DEALLOCATE&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;db_cursor;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;strong style=&quot;line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;–====================================&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;strong style=&quot;line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;MvM&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/6376321708511481914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/database-users-and-their-db-roles-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/6376321708511481914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/6376321708511481914'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/database-users-and-their-db-roles-sql.html' title='Database, Users and their DB Roles (SQL Server 2000 &amp; 2005)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5206410214044650233.post-7619182342005262303</id><published>2012-07-12T22:11:00.001+10:00</published><updated>2012-07-23T13:32:10.581+10:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2000"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2005"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server 2008"/><title type='text'>Query to find Users and their Database Roles in SQL Server 2000</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;SELECT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;USER_NAME&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;memberuid&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;UserName&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: magenta; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;USER_NAME&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;groupuid&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;as&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;Role&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;FROM&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: green; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;sysmembers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small; line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: left;&quot;&gt;
&lt;strong style=&quot;line-height: inherit; margin: 0px; padding: 0px;&quot;&gt;MvM&lt;/strong&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbafamily.blogspot.com/feeds/7619182342005262303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/query-to-find-users-and-their-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/7619182342005262303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5206410214044650233/posts/default/7619182342005262303'/><link rel='alternate' type='text/html' href='http://sqldbafamily.blogspot.com/2012/07/query-to-find-users-and-their-database.html' title='Query to find Users and their Database Roles in SQL Server 2000'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>