<?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>Head.SmackOnTable(); &#187; SQL</title>
	<atom:link href="http://www.unauthorised-access.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.unauthorised-access.com</link>
	<description>Contains Nuts.</description>
	<lastBuildDate>Fri, 02 Jul 2010 17:46:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Deleting all data from a Database</title>
		<link>http://www.unauthorised-access.com/2009/12/deleting-all-data-from-a-database/</link>
		<comments>http://www.unauthorised-access.com/2009/12/deleting-all-data-from-a-database/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 17:09:04 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=364</guid>
		<description><![CDATA[SELECT 'ALTER TABLE ' +  OBJECT_NAME(f.parent_object_id) + ' DROP CONSTRAINT [' + f.name + ']' FROM sys.foreign_keys AS f INNER JOIN sys.foreign_key_columns AS fc ON f.OBJECT_ID = fc.constraint_object_id UNION ALL SELECT 'TRUNCATE TABLE ' + name FROM dbo.sysobjects WHERE (type = 'u') and name != 'sysdiagrams' UNION ALL SELECT 'ALTER TABLE ' +  OBJECT_NAME(f.parent_object_id) + [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: sql;">

SELECT 'ALTER TABLE ' +  OBJECT_NAME(f.parent_object_id) + ' DROP CONSTRAINT [' + f.name + ']'
FROM sys.foreign_keys AS f
INNER JOIN sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id
UNION ALL
SELECT 'TRUNCATE TABLE ' + name FROM dbo.sysobjects WHERE (type = 'u') and name != 'sysdiagrams'
UNION ALL
SELECT 'ALTER TABLE ' +  OBJECT_NAME(f.parent_object_id) + ' ADD CONSTRAINT '  + f.name + ' FOREIGN KEY (' + COL_NAME(fc.parent_object_id, fc.parent_column_id) + ') REFERENCES ' + OBJECT_NAME (f.referenced_object_id) + '(' + COL_NAME(fc.referenced_object_id, fc.referenced_column_id) + ')' FROM sys.foreign_keys AS f INNER JOIN sys.foreign_key_columns AS fc ON f.OBJECT_ID = fc.constraint_object_id
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/12/deleting-all-data-from-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
