<?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-8274147423123333851</id><updated>2024-08-29T05:49:14.040+01:00</updated><category term="Miscellaneous"/><category term="SQL"/><title type='text'>MRP&#39;s Blog</title><subtitle type='html'>MRP is a senior web developer who writes about .NetCore, AWS, Azure</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ipazooki.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8274147423123333851/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://ipazooki.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>MRP</name><uri>http://www.blogger.com/profile/12324126227193508489</uri><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>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8274147423123333851.post-1254978716296538680</id><published>2009-12-17T06:52:00.002+00:00</published><updated>2009-12-17T07:00:50.454+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Delete Records from multiple tables</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img alt=&quot;SQL Server&quot; height=&quot;126&quot; longdesc=&quot;SQL&quot; src=&quot;http://i930.photobucket.com/albums/ad150/iPazooki/Programming/microsoft-sql-server-2008-logo.jpg&quot; width=&quot;320&quot; /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,Geneva,Tahoma,sans-serif; font-size: x-small; font-style: normal; font-weight: normal; text-align: justify;&quot;&gt;In many cases you may want to delete All the records from multiple tables . form &lt;br /&gt;
example you have generated tast data with&lt;br /&gt;
&lt;a href=&quot;http://www.red-gate.com/products/SQL_Data_Generator/index.htm&quot; style=&quot;color: #990033;&quot;&gt;&lt;br /&gt;
SQL Data Generator&lt;/a&gt; and know you want to delete all the records in tabels at once.&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,Geneva,Tahoma,sans-serif; font-size: x-small; text-align: justify;&quot;&gt;for this goal you can use this code :&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background-color: #d9d2e9; color: maroon; font-size: small; padding: 5px; text-align: left;&quot;&gt;EXEC sp_msforeachtable &#39;ALTER TABLE ? NOCHECK CONSTRAINT ALL&#39;;&lt;br /&gt;
&lt;br /&gt;
EXEC sp_msforeachtable &#39;DELETE FROM ?&#39;;&lt;br /&gt;
&lt;br /&gt;
EXEC sp_msforeachtable &#39;ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL&#39;;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,Geneva,Tahoma,sans-serif; font-size: x-small; font-style: normal; font-weight: normal; text-align: justify;&quot;&gt;&lt;br /&gt;
you my ask that way you haven&#39;t use &quot;Truncate Table&quot; insted of &quot;Delete From&quot; !!!&lt;br /&gt;
&lt;br /&gt;
the answer is in some cases you may have foregn key and &quot;Truncate Table&quot; doesn&#39;t &lt;br /&gt;
work in this case. But if you don&#39;t have any FK constraints you can use this code &lt;br /&gt;
insted that is more faster and better :&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background-color: #d9d2e9; color: maroon; font-size: small; padding: 5px; text-align: left;&quot;&gt;EXEC sp_msforeachtable &#39;ALTER TABLE ? NOCHECK CONSTRAINT ALL&#39;;&lt;br /&gt;
&lt;br /&gt;
EXEC sp_msforeachtable &#39;TRUNCATE TABLE ?&#39;;&lt;br /&gt;
&lt;br /&gt;
EXEC sp_msforeachtable &#39;ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL&#39;;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;see my blog Feed at http://feeds.feedburner.com/PazookisBlog&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ipazooki.blogspot.com/feeds/1254978716296538680/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ipazooki.blogspot.com/2009/12/delete-records-from-multiple-tables.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8274147423123333851/posts/default/1254978716296538680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8274147423123333851/posts/default/1254978716296538680'/><link rel='alternate' type='text/html' href='http://ipazooki.blogspot.com/2009/12/delete-records-from-multiple-tables.html' title='Delete Records from multiple tables'/><author><name>MRP</name><uri>http://www.blogger.com/profile/12324126227193508489</uri><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="http://i930.photobucket.com/albums/ad150/iPazooki/Programming/th_microsoft-sql-server-2008-logo.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8274147423123333851.post-4928907258147964568</id><published>2009-09-27T14:27:00.001+01:00</published><updated>2009-09-27T14:29:29.664+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Miscellaneous"/><title type='text'>Happy new Blog</title><content type='html'>I&#39;m glad to say that this is my new blog and it&#39;s my first post ...&lt;div class=&quot;blogger-post-footer&quot;&gt;see my blog Feed at http://feeds.feedburner.com/PazookisBlog&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ipazooki.blogspot.com/feeds/4928907258147964568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ipazooki.blogspot.com/2009/09/happy-new-blog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8274147423123333851/posts/default/4928907258147964568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8274147423123333851/posts/default/4928907258147964568'/><link rel='alternate' type='text/html' href='http://ipazooki.blogspot.com/2009/09/happy-new-blog.html' title='Happy new Blog'/><author><name>MRP</name><uri>http://www.blogger.com/profile/12324126227193508489</uri><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>