﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><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>IT博客-Victor.Stone-随笔分类-DB</title><link>http://www.cnitblog.com/sca/category/8816.html</link><description>dot net 备忘录</description><language>zh-cn</language><lastBuildDate>Wed, 28 Sep 2011 19:50:06 GMT</lastBuildDate><pubDate>Wed, 28 Sep 2011 19:50:06 GMT</pubDate><ttl>60</ttl><item><title>数据库附加</title><link>http://www.cnitblog.com/sca/archive/2010/12/16/72314.html</link><dc:creator>Victor.Stone</dc:creator><author>Victor.Stone</author><pubDate>Thu, 16 Dec 2010 00:37:00 GMT</pubDate><guid>http://www.cnitblog.com/sca/archive/2010/12/16/72314.html</guid><wfw:comment>http://www.cnitblog.com/sca/comments/72314.html</wfw:comment><comments>http://www.cnitblog.com/sca/archive/2010/12/16/72314.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/sca/comments/commentRss/72314.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/sca/services/trackbacks/72314.html</trackback:ping><description><![CDATA[CREATE DATABASE [abc] ON <br>( FILENAME = N'E:\db\abc.mdf' ),<br>( FILENAME = N'E:\db\abc_log.ldf' )<br>&nbsp;FOR ATTACH<br>GO<br>if not exists <br>(select name from master.sys.databases sd <br>where name = N'abc' and SUSER_SNAME(sd.owner_sid) = SUSER_SNAME() ) <br>EXEC [abc].dbo.sp_changedbowner @loginame=N'sa', @map=false<br>GO<br><img src ="http://www.cnitblog.com/sca/aggbug/72314.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/sca/" target="_blank">Victor.Stone</a> 2010-12-16 08:37 <a href="http://www.cnitblog.com/sca/archive/2010/12/16/72314.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>收缩SQL Server日志的大小</title><link>http://www.cnitblog.com/sca/archive/2010/11/13/71265.html</link><dc:creator>Victor.Stone</dc:creator><author>Victor.Stone</author><pubDate>Sat, 13 Nov 2010 03:52:00 GMT</pubDate><guid>http://www.cnitblog.com/sca/archive/2010/11/13/71265.html</guid><description><![CDATA[<div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><span style="COLOR: #008080">--</span><span style="COLOR: #008080">--收缩日志1：</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">backup</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">log</span><span style="COLOR: #000000">&nbsp;MYDB&nbsp;</span><span style="COLOR: #0000ff">with</span><span style="COLOR: #000000">&nbsp;NO_LOG<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">backup</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">log</span><span style="COLOR: #000000">&nbsp;MYDB&nbsp;</span><span style="COLOR: #0000ff">with</span><span style="COLOR: #000000">&nbsp;TRUNCATE_ONLY<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">DBCC</span><span style="COLOR: #000000">&nbsp;SHRINKDATABASE(MYDB)<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">--收缩日志2：</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;NOCOUNT&nbsp;ONDECLARE&nbsp;</span><span style="COLOR: #008000">@LogicalFileName</span><span style="COLOR: #000000">&nbsp;sysname,</span><span style="COLOR: #008000">@MaxMinutes</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000; FONT-WEIGHT: bold">INT</span><span style="COLOR: #000000">,</span><span style="COLOR: #008000">@NewSize</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000; FONT-WEIGHT: bold">INT</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">USE</span><span style="COLOR: #000000">&nbsp;Marias&nbsp;</span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;要操作的数据库名</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@LogicalFileName</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">Marias_log</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">,&nbsp;&nbsp;</span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;日志文件名</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #008000">@MaxMinutes</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000; FONT-WEIGHT: bold">10</span><span style="COLOR: #000000">,&nbsp;&nbsp;</span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;Limit&nbsp;on&nbsp;time&nbsp;allowed&nbsp;to&nbsp;wraplog.</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #008000">@NewSize</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000; FONT-WEIGHT: bold">100</span><span style="COLOR: #000000">&nbsp;&nbsp;</span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;你想设定的日志文件的大小(M)</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;Setup&nbsp;/&nbsp;initialize</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">DECLARE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@OriginalSize</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000; FONT-WEIGHT: bold">int</span><span style="COLOR: #000000">&nbsp;<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@OriginalSize</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;size&nbsp;</span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000">&nbsp;sysfiles&nbsp;</span><span style="COLOR: #0000ff">WHERE</span><span style="COLOR: #000000">&nbsp;name&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@LogicalFileName</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">Original&nbsp;Size&nbsp;of&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">db_name</span><span style="COLOR: #000000">()&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">&nbsp;LOG&nbsp;is&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">CONVERT</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000; FONT-WEIGHT: bold">VARCHAR</span><span style="COLOR: #000000">(</span><span style="COLOR: #800000; FONT-WEIGHT: bold">30</span><span style="COLOR: #000000">),</span><span style="COLOR: #008000">@OriginalSize</span><span style="COLOR: #000000">)&nbsp;<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">&nbsp;8K&nbsp;pages&nbsp;or&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #ff00ff">CONVERT</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000; FONT-WEIGHT: bold">VARCHAR</span><span style="COLOR: #000000">(</span><span style="COLOR: #800000; FONT-WEIGHT: bold">30</span><span style="COLOR: #000000">),(</span><span style="COLOR: #008000">@OriginalSize</span><span style="COLOR: #808080">*</span><span style="COLOR: #800000; FONT-WEIGHT: bold">8</span><span style="COLOR: #808080">/</span><span style="COLOR: #800000; FONT-WEIGHT: bold">1024</span><span style="COLOR: #000000">))&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">MB</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000">&nbsp;sysfiles<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">WHERE</span><span style="COLOR: #000000">&nbsp;name&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@LogicalFileName</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">CREATE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">TABLE</span><span style="COLOR: #000000">&nbsp;DummyTrans(DummyColumn&nbsp;</span><span style="COLOR: #000000; FONT-WEIGHT: bold">char</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #800000; FONT-WEIGHT: bold">8000</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #808080">not</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">)<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">DECLARE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@Counter</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000; FONT-WEIGHT: bold">INT</span><span style="COLOR: #000000">,</span><span style="COLOR: #008000">@StartTime</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000; FONT-WEIGHT: bold">DATETIME</span><span style="COLOR: #000000">,</span><span style="COLOR: #008000">@TruncLog</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000; FONT-WEIGHT: bold">VARCHAR</span><span style="COLOR: #000000">(</span><span style="COLOR: #800000; FONT-WEIGHT: bold">255</span><span style="COLOR: #000000">)<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@StartTime</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">GETDATE</span><span style="COLOR: #000000">(),</span><span style="COLOR: #008000">@TruncLog</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">BACKUP&nbsp;LOG&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">db_name</span><span style="COLOR: #000000">()&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">&nbsp;WITH&nbsp;TRUNCATE_ONLY</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">DBCC</span><span style="COLOR: #000000">&nbsp;SHRINKFILE&nbsp;(</span><span style="COLOR: #008000">@LogicalFileName</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #008000">@NewSize</span><span style="COLOR: #000000">)<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">EXEC</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #008000">@TruncLog</span><span style="COLOR: #000000">)<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;Wrap&nbsp;the&nbsp;log&nbsp;if&nbsp;necessary.</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">WHILE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@MaxMinutes</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">DATEDIFF</span><span style="COLOR: #000000">&nbsp;(mi,&nbsp;</span><span style="COLOR: #008000">@StartTime</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #ff00ff">GETDATE</span><span style="COLOR: #000000">())&nbsp;</span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;time&nbsp;has&nbsp;notexpired</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #808080">AND</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@OriginalSize</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;size&nbsp;</span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000">&nbsp;sysfiles&nbsp;</span><span style="COLOR: #0000ff">WHERE</span><span style="COLOR: #000000">&nbsp;name&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #008000">@LogicalFileName</span><span style="COLOR: #000000">)<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #808080">AND</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #008000">@OriginalSize</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">*</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000; FONT-WEIGHT: bold">8</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">/</span><span style="COLOR: #800000; FONT-WEIGHT: bold">1024</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #808080">&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@NewSize</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">BEGIN</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;Outer&nbsp;loop.</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@Counter</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000; FONT-WEIGHT: bold">0</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">WHILE</span><span style="COLOR: #000000">&nbsp;((</span><span style="COLOR: #008000">@Counter</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">&lt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@OriginalSize</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">/</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000; FONT-WEIGHT: bold">16</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #808080">AND</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #008000">@Counter</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">&lt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000; FONT-WEIGHT: bold">50000</span><span style="COLOR: #000000">))<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">BEGIN</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;update</span><span style="COLOR: #008080"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">INSERT</span><span style="COLOR: #000000">&nbsp;DummyTrans&nbsp;</span><span style="COLOR: #0000ff">VALUES</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">Fill&nbsp;Log</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">)<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">DELETE</span><span style="COLOR: #000000">&nbsp;DummyTrans&nbsp;<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@Counter</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@Counter</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000; FONT-WEIGHT: bold">1</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">END</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;&nbsp;<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">EXEC</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #008000">@TruncLog</span><span style="COLOR: #000000">)<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">END</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">Final&nbsp;Size&nbsp;of&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">db_name</span><span style="COLOR: #000000">()&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">&nbsp;LOG&nbsp;is&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">&nbsp;<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">CONVERT</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000; FONT-WEIGHT: bold">VARCHAR</span><span style="COLOR: #000000">(</span><span style="COLOR: #800000; FONT-WEIGHT: bold">30</span><span style="COLOR: #000000">),size)&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">&nbsp;8K&nbsp;pages&nbsp;or&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">&nbsp;<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">CONVERT</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000; FONT-WEIGHT: bold">VARCHAR</span><span style="COLOR: #000000">(</span><span style="COLOR: #800000; FONT-WEIGHT: bold">30</span><span style="COLOR: #000000">),(size</span><span style="COLOR: #808080">*</span><span style="COLOR: #800000; FONT-WEIGHT: bold">8</span><span style="COLOR: #808080">/</span><span style="COLOR: #800000; FONT-WEIGHT: bold">1024</span><span style="COLOR: #000000">))&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">MB</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000">&nbsp;sysfiles<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">WHERE</span><span style="COLOR: #000000">&nbsp;name&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@LogicalFileName</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">DROP</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">TABLE</span><span style="COLOR: #000000">&nbsp;DummyTrans<br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;NOCOUNT&nbsp;</span><span style="COLOR: #0000ff">OFF</span><span style="COLOR: #000000"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif"></span></div><img src ="http://www.cnitblog.com/sca/aggbug/71265.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/sca/" target="_blank">Victor.Stone</a> 2010-11-13 11:52 <a href="http://www.cnitblog.com/sca/archive/2010/11/13/71265.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>