<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Microsoft SQL Server</title><link>http://radcom.ir/weblog/amir/category/81.aspx</link><description>Microsoft SQL Server</description><managingEditor>&amp;#1575;&amp;#1605;&amp;#1610;&amp;#1585; &amp;#1605;&amp;#1610;&amp;#1585;&amp;#1603;&amp;#1605;&amp;#1575;&amp;#1604;&amp;#1610;</managingEditor><dc:language>fa</dc:language><generator>SAMPA Weblogs</generator><item><dc:creator>&amp;#1575;&amp;#1605;&amp;#1610;&amp;#1585; &amp;#1605;&amp;#1610;&amp;#1585;</dc:creator><title>Empty All tables content in SQL Server</title><link>http://radcom.ir/weblog/amir/archive/2008/02/20/42332.aspx</link><pubDate>Wed, 20 Feb 2008 15:10:00 GMT</pubDate><guid>http://radcom.ir/weblog/amir/archive/2008/02/20/42332.aspx</guid><wfw:comment>http://radcom.ir/weblog/amir/comments/42332.aspx</wfw:comment><comments>http://radcom.ir/weblog/amir/archive/2008/02/20/42332.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://radcom.ir/weblog/amir/comments/commentRss/42332.aspx</wfw:commentRss><trackback:ping>http://radcom.ir/weblog/amir/services/trackbacks/42332.aspx</trackback:ping><description>&lt;table dir=ltr &gt;&lt;tr&gt;&lt;td style='font-size:12px'&gt;
&lt;PRE&gt;&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;DECLARE&lt;/span&gt; @tableCatalog &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;VARCHAR&lt;/span&gt; (1024) , 

@tableSchema &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;VARCHAR&lt;/span&gt; (1024), @tableName &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;VARCHAR&lt;/span&gt; (1024), @tableType &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;VARCHAR&lt;/span&gt; (1024)
&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;DECLARE&lt;/span&gt; cursorTemp &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;CURSOR&lt;/span&gt; &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;FOR&lt;/span&gt;
&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;SELECT&lt;/span&gt; * &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;FROM&lt;/span&gt; INFORMATION_SCHEMA.TABLES
&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;OPEN&lt;/span&gt; cursorTemp
&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;FETCH&lt;/span&gt; cursorTemp &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;INTO&lt;/span&gt; @tableCatalog, @tableSchema, @tableName, @tableType


&lt;span style="color: Green; font-family: Courier New; font-size: 12px; background-color: White"&gt;-- start the main processing loop.
&lt;/span&gt;&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;WHILE&lt;/span&gt; @@Fetch_Status = 0
&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;BEGIN&lt;/span&gt;
	&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;EXEC&lt;/span&gt; (' &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;ALTER&lt;/span&gt; &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;TABLE&lt;/span&gt; '+@tableName+' &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;NOCHECK&lt;/span&gt; &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;CONSTRAINT&lt;/span&gt; &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;ALL&lt;/span&gt;;' +
	' &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;DELETE&lt;/span&gt; &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;FROM&lt;/span&gt; '+ @tableName +';'+
	' &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;ALTER&lt;/span&gt; &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;TABLE&lt;/span&gt; '+@tableName+' &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;CHECK&lt;/span&gt; &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;CONSTRAINT&lt;/span&gt; &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;ALL&lt;/span&gt; ') 
	&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;FETCH&lt;/span&gt; cursorTemp &lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;INTO&lt;/span&gt; @tableCatalog, @tableSchema, @tableName, @tableType
&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;END&lt;/span&gt;

&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;CLOSE&lt;/span&gt; cursorTemp
&lt;span style="color: Blue; font-family: Courier New; font-size: 12px; background-color: White"&gt;DEALLOCATE&lt;/span&gt; cursorTemp&lt;/PRE&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;img src ="http://radcom.ir/weblog/amir/aggbug/42332.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>&amp;#1575;&amp;#1605;&amp;#1610;&amp;#1585; &amp;#1605;&amp;#1610;&amp;#1585;</dc:creator><title>Kill all process related to database with T-SQL</title><link>http://radcom.ir/weblog/amir/archive/2007/11/20/42132.aspx</link><pubDate>Tue, 20 Nov 2007 08:52:00 GMT</pubDate><guid>http://radcom.ir/weblog/amir/archive/2007/11/20/42132.aspx</guid><wfw:comment>http://radcom.ir/weblog/amir/comments/42132.aspx</wfw:comment><comments>http://radcom.ir/weblog/amir/archive/2007/11/20/42132.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://radcom.ir/weblog/amir/comments/commentRss/42132.aspx</wfw:commentRss><trackback:ping>http://radcom.ir/weblog/amir/services/trackbacks/42132.aspx</trackback:ping><description>&lt;TABLE class=" FCK__ShowTableBorders" dir=ltr cellSpacing=1 cellPadding=1 width="100%" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;PRE&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;TABLE&lt;/SPAN&gt; #TmpWho
(spid &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;INT&lt;/SPAN&gt;, ecid &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;INT&lt;/SPAN&gt;, status &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;VARCHAR&lt;/SPAN&gt;(150), &lt;BR&gt;loginame &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;VARCHAR&lt;/SPAN&gt;(150), hostname &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;VARCHAR&lt;/SPAN&gt;(150), &lt;/PRE&gt;&lt;PRE&gt;blk &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;INT&lt;/SPAN&gt;, dbname &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;VARCHAR&lt;/SPAN&gt;(150), cmd &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;VARCHAR&lt;/SPAN&gt;(150))

&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;INSERT&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;INTO&lt;/SPAN&gt; #TmpWho
&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;EXEC&lt;/SPAN&gt;       sp_who

&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;DECLARE&lt;/SPAN&gt; @spid &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;INT&lt;/SPAN&gt;     
&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;DECLARE&lt;/SPAN&gt; @getspid &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;CURSOR&lt;/SPAN&gt;     

&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;SET&lt;/SPAN&gt; @getspid = &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;CURSOR&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;FOR&lt;/SPAN&gt;     
      &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;SELECT&lt;/SPAN&gt;       spid
      &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;FROM&lt;/SPAN&gt;      #TmpWho
      &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;WHERE&lt;/SPAN&gt;       dbname = '&lt;FONT color=#ff0000&gt;YOURDBNAME&lt;/FONT&gt;'

&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;OPEN&lt;/SPAN&gt; @getspid     

&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;FETCH&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;NEXT&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;FROM&lt;/SPAN&gt; @getspid &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;INTO&lt;/SPAN&gt; @spid     

&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;WHILE&lt;/SPAN&gt; @@FETCH_STATUS = 0 
&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;BEGIN&lt;/SPAN&gt;
 &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;KILL&lt;/SPAN&gt; @spid &lt;SPAN style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;--SELECT @spid works fine here
&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;FETCH&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;NEXT&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;FROM&lt;/SPAN&gt; @getspid &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;INTO&lt;/SPAN&gt; @spid
&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;END&lt;/SPAN&gt;
&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;CLOSE&lt;/SPAN&gt; @getspid 
&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;DEALLOCATE&lt;/SPAN&gt; @getspid 

&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;DROP&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;TABLE&lt;/SPAN&gt; #TmpWho

&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;img src ="http://radcom.ir/weblog/amir/aggbug/42132.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>&amp;#1575;&amp;#1605;&amp;#1610;&amp;#1585; &amp;#1605;&amp;#1610;&amp;#1585;</dc:creator><title>How to Get ALL SQL Server process list?</title><link>http://radcom.ir/weblog/amir/archive/2007/11/20/42131.aspx</link><pubDate>Tue, 20 Nov 2007 08:49:00 GMT</pubDate><guid>http://radcom.ir/weblog/amir/archive/2007/11/20/42131.aspx</guid><wfw:comment>http://radcom.ir/weblog/amir/comments/42131.aspx</wfw:comment><comments>http://radcom.ir/weblog/amir/archive/2007/11/20/42131.aspx#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://radcom.ir/weblog/amir/comments/commentRss/42131.aspx</wfw:commentRss><trackback:ping>http://radcom.ir/weblog/amir/services/trackbacks/42131.aspx</trackback:ping><description>&lt;P dir=ltr&gt;just run &lt;FONT color=#0000ff&gt;sp_who&lt;/FONT&gt; stored procedure.&lt;/P&gt;&lt;img src ="http://radcom.ir/weblog/amir/aggbug/42131.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>&amp;#1575;&amp;#1605;&amp;#1610;&amp;#1585; &amp;#1605;&amp;#1610;&amp;#1585;</dc:creator><title>Set database to work in Single User or Multi User Mode</title><link>http://radcom.ir/weblog/amir/archive/2007/11/20/42130.aspx</link><pubDate>Tue, 20 Nov 2007 08:43:00 GMT</pubDate><guid>http://radcom.ir/weblog/amir/archive/2007/11/20/42130.aspx</guid><wfw:comment>http://radcom.ir/weblog/amir/comments/42130.aspx</wfw:comment><comments>http://radcom.ir/weblog/amir/archive/2007/11/20/42130.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://radcom.ir/weblog/amir/comments/commentRss/42130.aspx</wfw:commentRss><trackback:ping>http://radcom.ir/weblog/amir/services/trackbacks/42130.aspx</trackback:ping><description>&lt;P dir=ltr&gt;&lt;FONT face="Courier New"&gt;There are two ways :&lt;/FONT&gt;&lt;/P&gt;
&lt;OL dir=ltr&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;EXEC&lt;/SPAN&gt; sp_dboption 'pubs', 'single &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;user&lt;/SPAN&gt;', '&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;TRUE&lt;/SPAN&gt;'&lt;BR&gt;&lt;/DIV&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;alter&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;database&lt;/SPAN&gt; pubs &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;set&lt;/SPAN&gt; SINGLE_USER  &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;WITH&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;ROLLBACK&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;IMMEDIATE&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;PRE dir=ltr&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;&lt;FONT color=#000000 size=2&gt;To deactive single user mode :&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;OL dir=ltr&gt;
&lt;LI&gt;&lt;PRE&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;&lt;FONT color=#000000 size=2&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;EXEC&lt;/SPAN&gt; sp_dboption 'pubs', 'sing&lt;FONT color=#000000&gt;le &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;user&lt;/SPAN&gt;&lt;/FONT&gt;', '&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;FALSE&lt;/SPAN&gt;'&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;LI&gt;&lt;PRE&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;&lt;FONT color=#000000 size=2&gt;2- &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;alter&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;database&lt;/SPAN&gt; pubs &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;set&lt;/SPAN&gt; MULTI_USER &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: white"&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/SPAN&gt;&lt;img src ="http://radcom.ir/weblog/amir/aggbug/42130.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>