<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>belle's sql musings &#187; DBA Toolbox / T-SQL Scripts</title>
	<atom:link href="http://www.sqlmusings.com/category/dba-toolbox-t-sql-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sqlmusings.com</link>
	<description>ramblings, discoveries, tutorials on sql server and other database stuff</description>
	<lastBuildDate>Tue, 03 Aug 2010 18:04:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Excellent Free Ebooks from RedGate</title>
		<link>http://www.sqlmusings.com/2009/10/07/excellent-free-ebooks-from-redgate/</link>
		<comments>http://www.sqlmusings.com/2009/10/07/excellent-free-ebooks-from-redgate/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 06:39:25 +0000</pubDate>
		<dc:creator>belle</dc:creator>
				<category><![CDATA[DBA Toolbox / T-SQL Scripts]]></category>
		<category><![CDATA[Ebooks]]></category>
		<category><![CDATA[Resources/References]]></category>

		<guid isPermaLink="false">http://www.sqlmusings.com/?p=1096</guid>
		<description><![CDATA[Excellent Free Ebooks from RedGate
SQL Server eBook Selection
1. Protecting SQL Server Data by John Magnabosco
2. The Art of High Performance SQL by Grant Fritchey
3. The Art of XSD by Jacob Sebastian
4. Two Minute SQL Server Stumpers Vol. 5
DBA Ebooks Bundle
1. Mastering SQL Server Profiler
2. Brad&#8217;s Sure Guide to SQL Server 2008
3. Brad McGehee&#8217;s DBA Best [...]

<p style="margin-top:25px">Related posts:<ol><li><a href='http://www.sqlmusings.com/2008/10/04/free-sql-server-ebooksresources/' rel='bookmark' title='Permanent Link: Free SQL Server Ebooks/Resources'>Free SQL Server Ebooks/Resources</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/03/15/redgate-ebook-mastering-sql-server-profiler/' rel='bookmark' title='Permanent Link: RedGate Free Ebook: Mastering SQL Server Profiler'>RedGate Free Ebook: Mastering SQL Server Profiler</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2008/11/07/sql-server-scalability-etc-free-ebooks/' rel='bookmark' title='Permanent Link: SQL Server Scalability etc &#8211; Free Ebooks'>SQL Server Scalability etc &#8211; Free Ebooks</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2008/05/19/currently-reading-grant-fritcheys-new-book/' rel='bookmark' title='Permanent Link: Currently Reading Grant Fritchey&#8217;s New Book'>Currently Reading Grant Fritchey&#8217;s New Book</a> <small>...</small></li></ol>]]></description>
		<wfw:commentRss>http://www.sqlmusings.com/2009/10/07/excellent-free-ebooks-from-redgate/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL Server XML Red Gate Ebook, XQuery Labs</title>
		<link>http://www.sqlmusings.com/2009/06/08/sql-server-xml-red-gate-ebook-xquery-labs/</link>
		<comments>http://www.sqlmusings.com/2009/06/08/sql-server-xml-red-gate-ebook-xquery-labs/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 02:35:09 +0000</pubDate>
		<dc:creator>belle</dc:creator>
				<category><![CDATA[DBA Toolbox / T-SQL Scripts]]></category>
		<category><![CDATA[Ebooks]]></category>
		<category><![CDATA[Resources/References]]></category>
		<category><![CDATA[SQLXML]]></category>
		<category><![CDATA[T-SQL Tips and Tricks]]></category>
		<category><![CDATA[Ebook]]></category>
		<category><![CDATA[SQLXML How To]]></category>
		<category><![CDATA[XSD]]></category>

		<guid isPermaLink="false">http://www.sqlmusings.com/?p=924</guid>
		<description><![CDATA[Jacob Sebastian is a SQL Server XML Guru!
Check out his collection for XQUery Labs. This is the first 12 of his series, and right now he has 43 and counting:

XQuery Sample Scripts
    * XQuery Lab 1 &#8211; Transforming rows to columns
    * XQuery Lab 2 &#8211; An example using [...]

<p style="margin-top:25px">Related posts:<ol><li><a href='http://www.sqlmusings.com/2008/07/01/learning-sqlxml-on-sql-server-2005-series-of-tutorials/' rel='bookmark' title='Permanent Link: Learning SQLXML on SQL Server 2005 – series of tutorials'>Learning SQLXML on SQL Server 2005 – series of tutorials</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/11/have-you-downloaded-the-free-ms-press-sql-server-ebook-yet/' rel='bookmark' title='Permanent Link: Have You Downloaded the Free MS Press SQL Server 2008 Ebook Yet?'>Have You Downloaded the Free MS Press SQL Server 2008 Ebook Yet?</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/03/15/redgate-ebook-mastering-sql-server-profiler/' rel='bookmark' title='Permanent Link: RedGate Free Ebook: Mastering SQL Server Profiler'>RedGate Free Ebook: Mastering SQL Server Profiler</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2010/04/14/sql-server-2008-r2-ssrs-free-ebook-training-kit-out/' rel='bookmark' title='Permanent Link: SQL Server 2008 R2 (SSRS) Free Ebook, Training Kit Out'>SQL Server 2008 R2 (SSRS) Free Ebook, Training Kit Out</a> <small>...</small></li></ol>]]></description>
		<wfw:commentRss>http://www.sqlmusings.com/2009/06/08/sql-server-xml-red-gate-ebook-xquery-labs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server PowerShell : Search for SQL Server Objects Using PowerShell</title>
		<link>http://www.sqlmusings.com/2009/06/04/sql-server-powershell-search-for-sql-server-objects-using-powershell/</link>
		<comments>http://www.sqlmusings.com/2009/06/04/sql-server-powershell-search-for-sql-server-objects-using-powershell/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 07:49:31 +0000</pubDate>
		<dc:creator>belle</dc:creator>
				<category><![CDATA[DBA Toolbox / T-SQL Scripts]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SMO]]></category>
		<category><![CDATA[SQL Server Powershell]]></category>

		<guid isPermaLink="false">http://www.sqlmusings.com/?p=860</guid>
		<description><![CDATA[I have posted previously 3 different ways of searching for SQL Server Objects (How to Search for Columns in SQL Server ). 
Here&#8217;s a fourth one! 
Check out how powerful and flexible PowerShell is when you need to look for a database object. In the script below, I only search databases, tables, columns, and indexes. [...]

<p style="margin-top:25px">Related posts:<ol><li><a href='http://www.sqlmusings.com/2009/05/16/how-to-search-for-columns-in-sql-server/' rel='bookmark' title='Permanent Link: How to Search for Columns in SQL Server'>How to Search for Columns in SQL Server</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/05/31/how-to-backup-sql-server-databases-using-smo-and-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Backup SQL Server Databases Using SMO and PowerShell'>SQL Server PowerShell : How to Backup SQL Server Databases Using SMO and PowerShell</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/03/sql-server-powershell-how-to-audit-your-sql-server-instance-properties-using-powershell-and-smo/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Audit Your SQL Server Instance Properties Using PowerShell and SMO'>SQL Server PowerShell : How to Audit Your SQL Server Instance Properties Using PowerShell and SMO</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Restore SQL Server Databases Using SMO and PowerShell'>SQL Server PowerShell : How to Restore SQL Server Databases Using SMO and PowerShell</a> <small>...</small></li></ol>]]></description>
		<wfw:commentRss>http://www.sqlmusings.com/2009/06/04/sql-server-powershell-search-for-sql-server-objects-using-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL Server PowerShell : How to Audit Your SQL Server Instance Properties Using PowerShell and SMO</title>
		<link>http://www.sqlmusings.com/2009/06/03/sql-server-powershell-how-to-audit-your-sql-server-instance-properties-using-powershell-and-smo/</link>
		<comments>http://www.sqlmusings.com/2009/06/03/sql-server-powershell-how-to-audit-your-sql-server-instance-properties-using-powershell-and-smo/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 07:11:27 +0000</pubDate>
		<dc:creator>belle</dc:creator>
				<category><![CDATA[DBA Toolbox / T-SQL Scripts]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SMO]]></category>
		<category><![CDATA[SQL Server Powershell]]></category>

		<guid isPermaLink="false">http://www.sqlmusings.com/?p=845</guid>
		<description><![CDATA[Here is a simple script to audit your SQL Server Instance Properties.
Note that the property names are not hardcoded. We query each of these properties, and use those to display the property values.
If you prefer, you can also query directly each of the properties of an instance. If this is the case, just specify your [...]

<p style="margin-top:25px">Related posts:<ol><li><a href='http://www.sqlmusings.com/2009/05/31/how-to-backup-sql-server-databases-using-smo-and-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Backup SQL Server Databases Using SMO and PowerShell'>SQL Server PowerShell : How to Backup SQL Server Databases Using SMO and PowerShell</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/04/sql-server-powershell-search-for-sql-server-objects-using-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : Search for SQL Server Objects Using PowerShell'>SQL Server PowerShell : Search for SQL Server Objects Using PowerShell</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Restore SQL Server Databases Using SMO and PowerShell'>SQL Server PowerShell : How to Restore SQL Server Databases Using SMO and PowerShell</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2008/10/13/how-to-connect-to-an-instance-name-using-smo/' rel='bookmark' title='Permanent Link: How to Connect to an Instance Name Using SMO'>How to Connect to an Instance Name Using SMO</a> <small>...</small></li></ol>]]></description>
		<wfw:commentRss>http://www.sqlmusings.com/2009/06/03/sql-server-powershell-how-to-audit-your-sql-server-instance-properties-using-powershell-and-smo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server PowerShell : How to Restore SQL Server Databases Using SMO and PowerShell</title>
		<link>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/</link>
		<comments>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 07:05:34 +0000</pubDate>
		<dc:creator>belle</dc:creator>
				<category><![CDATA[DBA Toolbox / T-SQL Scripts]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SMO]]></category>
		<category><![CDATA[SQL Server Powershell]]></category>

		<guid isPermaLink="false">http://www.sqlmusings.com/?p=809</guid>
		<description><![CDATA[A follow-up to my previous post: How to Restore SQL Server Databases Using SMO and PowerShell
In this post I will show you how you can restore your database to :
1. the existing database (same database name)
2. a different database (different database name, different mdf and ldf)
As with the previous post, to do a SQL Server [...]

<p style="margin-top:25px">Related posts:<ol><li><a href='http://www.sqlmusings.com/2009/05/31/how-to-backup-sql-server-databases-using-smo-and-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Backup SQL Server Databases Using SMO and PowerShell'>SQL Server PowerShell : How to Backup SQL Server Databases Using SMO and PowerShell</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/03/sql-server-powershell-how-to-audit-your-sql-server-instance-properties-using-powershell-and-smo/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Audit Your SQL Server Instance Properties Using PowerShell and SMO'>SQL Server PowerShell : How to Audit Your SQL Server Instance Properties Using PowerShell and SMO</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/04/sql-server-powershell-search-for-sql-server-objects-using-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : Search for SQL Server Objects Using PowerShell'>SQL Server PowerShell : Search for SQL Server Objects Using PowerShell</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/08/21/sql-server-powershell-how-to-view-your-ssrs-reports-rdl-using-powershell-and-reportviewer/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to View your SSRS Reports (rdl) Using PowerShell and ReportViewer'>SQL Server PowerShell : How to View your SSRS Reports (rdl) Using PowerShell and ReportViewer</a> <small>...</small></li></ol>]]></description>
		<wfw:commentRss>http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>SQL Server PowerShell : How to Backup SQL Server Databases Using SMO and PowerShell</title>
		<link>http://www.sqlmusings.com/2009/05/31/how-to-backup-sql-server-databases-using-smo-and-powershell/</link>
		<comments>http://www.sqlmusings.com/2009/05/31/how-to-backup-sql-server-databases-using-smo-and-powershell/#comments</comments>
		<pubDate>Sun, 31 May 2009 17:04:27 +0000</pubDate>
		<dc:creator>belle</dc:creator>
				<category><![CDATA[DBA Toolbox / T-SQL Scripts]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SMO]]></category>
		<category><![CDATA[SQL Server Powershell]]></category>

		<guid isPermaLink="false">http://www.sqlmusings.com/?p=787</guid>
		<description><![CDATA[PowerShell makes it easier to manage even your database backups and restore. 
To do a SQL Server backup in SQL Server, you will need to use the SMO SqlBackup method. In SQL Server 2008, you will need to load Microsoft.SqlServer.SmoExtended assembly otherwise, you will get the following error:

Cannot find type [Microsoft.SqlServer.Management.Smo.Backup]: make sure the assembly [...]

<p style="margin-top:25px">Related posts:<ol><li><a href='http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Restore SQL Server Databases Using SMO and PowerShell'>SQL Server PowerShell : How to Restore SQL Server Databases Using SMO and PowerShell</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/04/sql-server-powershell-search-for-sql-server-objects-using-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : Search for SQL Server Objects Using PowerShell'>SQL Server PowerShell : Search for SQL Server Objects Using PowerShell</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/03/sql-server-powershell-how-to-audit-your-sql-server-instance-properties-using-powershell-and-smo/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Audit Your SQL Server Instance Properties Using PowerShell and SMO'>SQL Server PowerShell : How to Audit Your SQL Server Instance Properties Using PowerShell and SMO</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/08/21/sql-server-powershell-how-to-view-your-ssrs-reports-rdl-using-powershell-and-reportviewer/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to View your SSRS Reports (rdl) Using PowerShell and ReportViewer'>SQL Server PowerShell : How to View your SSRS Reports (rdl) Using PowerShell and ReportViewer</a> <small>...</small></li></ol>]]></description>
		<wfw:commentRss>http://www.sqlmusings.com/2009/05/31/how-to-backup-sql-server-databases-using-smo-and-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL Server PowerShell : How to List SQL Server Services using PowerShell</title>
		<link>http://www.sqlmusings.com/2009/05/23/how-to-list-sql-server-services-using-powershell/</link>
		<comments>http://www.sqlmusings.com/2009/05/23/how-to-list-sql-server-services-using-powershell/#comments</comments>
		<pubDate>Sun, 24 May 2009 05:18:15 +0000</pubDate>
		<dc:creator>belle</dc:creator>
				<category><![CDATA[DBA Toolbox / T-SQL Scripts]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SQL Server Powershell]]></category>

		<guid isPermaLink="false">http://www.sqlmusings.com/?p=803</guid>
		<description><![CDATA[Catch: this lists any service that has &#8220;SQL&#8221; in it, so can potentially list MySQL services too  
ListAll SQL services


#list stopped SQL Server services
$computername = &#34;APHRODITE&#34;
Get-WmiObject win32_service -computername $computername &#124;
select name, state &#124;
where {
   ($_.name -like &#34;SQLAGENT*&#34; -or $_.name -like &#34;*SQL*&#34;) `
    }

Another way to do this:

#note ComputerManagement works [...]

<p style="margin-top:25px">Related posts:<ol><li><a href='http://www.sqlmusings.com/2009/06/04/sql-server-powershell-search-for-sql-server-objects-using-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : Search for SQL Server Objects Using PowerShell'>SQL Server PowerShell : Search for SQL Server Objects Using PowerShell</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/03/sql-server-powershell-how-to-audit-your-sql-server-instance-properties-using-powershell-and-smo/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Audit Your SQL Server Instance Properties Using PowerShell and SMO'>SQL Server PowerShell : How to Audit Your SQL Server Instance Properties Using PowerShell and SMO</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/05/31/how-to-backup-sql-server-databases-using-smo-and-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Backup SQL Server Databases Using SMO and PowerShell'>SQL Server PowerShell : How to Backup SQL Server Databases Using SMO and PowerShell</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/06/01/how-to-restore-sql-server-databases-using-smo-and-powershell/' rel='bookmark' title='Permanent Link: SQL Server PowerShell : How to Restore SQL Server Databases Using SMO and PowerShell'>SQL Server PowerShell : How to Restore SQL Server Databases Using SMO and PowerShell</a> <small>...</small></li></ol>]]></description>
		<wfw:commentRss>http://www.sqlmusings.com/2009/05/23/how-to-list-sql-server-services-using-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Get Definition for Stored Procedures, UDFs and Triggers using T-SQL</title>
		<link>http://www.sqlmusings.com/2009/05/17/how-to-get-definition-for-stored-procedures-udfs-and-triggers-using-t-sql/</link>
		<comments>http://www.sqlmusings.com/2009/05/17/how-to-get-definition-for-stored-procedures-udfs-and-triggers-using-t-sql/#comments</comments>
		<pubDate>Mon, 18 May 2009 03:51:29 +0000</pubDate>
		<dc:creator>belle</dc:creator>
				<category><![CDATA[DBA Toolbox / T-SQL Scripts]]></category>
		<category><![CDATA[T-SQL Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.sqlmusings.com/?p=765</guid>
		<description><![CDATA[If you want to list the definition for a stored procedure, User Defined Function, or Trigger, you can use one of the following ways:

Alternative 1: sp_helptext (T-SQL)

-- using sp_helptext

sp_helptext 'dbo.your_object_name'


Alternative 2: syscomments (T-SQL)

-- using syscomments

SELECT [text]
FROM sys.syscomments
WHERE OBJECT_NAME(id) = 'your_object_name'


Alternative 3: OBJECT_DEFINITION (T-SQL)

-- using built in function OBJECT_DEFINITION

SELECT OBJECT_DEFINITION(OBJECT_ID('your_object_name'))




Share : 


	
	
	
	
	
	
	




Related posts:How to Drop All [...]

<p style="margin-top:25px">Related posts:<ol><li><a href='http://www.sqlmusings.com/2009/03/15/how-to-drop-all-stored-procedures-in-your-database/' rel='bookmark' title='Permanent Link: How to Drop All Stored Procedures in Your Database'>How to Drop All Stored Procedures in Your Database</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2008/10/05/using-ddl-triggers/' rel='bookmark' title='Permanent Link: Using DDL Triggers'>Using DDL Triggers</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/05/16/how-to-search-for-columns-in-sql-server/' rel='bookmark' title='Permanent Link: How to Search for Columns in SQL Server'>How to Search for Columns in SQL Server</a> <small>...</small></li><li><a href='http://www.sqlmusings.com/2009/05/09/handling-division-by-zero-scenarios-in-t-sql/' rel='bookmark' title='Permanent Link: Handling Division By Zero Scenarios in T-SQL'>Handling Division By Zero Scenarios in T-SQL</a> <small>...</small></li></ol>]]></description>
		<wfw:commentRss>http://www.sqlmusings.com/2009/05/17/how-to-get-definition-for-stored-procedures-udfs-and-triggers-using-t-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
