SQL SERVER 查看sql语句性能与执行时间

【方法一】

set statistics profile on
set statistics io on
set statistics time on
go
--sql语句
go
set statistics profile off
set statistics io off
set statistics time off

 

【方法二】

declare @starttime datetime

set @starttime=getdate()

begin

--sql语句

end

select datediff(ms,@starttime,getdate())