获得某段SQL语句执行时间的办法

<ins class="adsbygoogle" style="display:inline-block;width:336px;height:280px" data-ad-client="ca-pub-1944176156128447" data-ad-slot="2755181948">ins>

 

有时候我们需要知道一段SQL语句执行的时间有多长。下面是其中一种办法。

 

 

declare @preDate Datetime

select @preDate = getdate()

print @preDate

select datepart(ms,@preDate) as ms, datepart(ss,@preDate) as second,datepart(mi,@preDate) as minute

go

--需要测试的SQL语句

go

declare @preDate Datetime

SELECT @preDate= getdate()

select datepart(ms,@preDate) as ms, datepart(ss,@preDate) as second,datepart(mi,@preDate) as minute

 

这样可以知道你的语句到底运行了多少毫秒。

 

posted on 2009-02-16 17:14  Becool  阅读(638)  评论(0编辑  收藏  举报