天天看点

查看sql的执行效率

一、显示的信息比较全

SET STATISTICS io ON

        SET STATISTICS time ON

        go

  ---你要测试的sql语句

select g.grpName,t.grpID,t.flowID,t.typeName,t.description

from hyGroup g  ,hyType t where  t.grpID = g.flowID      

        go

        SET STATISTICS profile OFF

        SET STATISTICS io OFF

        SET STATISTICS time OFF

二、只显示执行时间

declare @d datetime set @d=getdate()

  ---你要测试的sql语句

select * from tablename

select[语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())