1:下面這種是比較簡單的查詢方法,通過查詢前的時間和查詢後的時間差來計算的
復制代碼 代碼如下:
declare @begin_date datetime
declare @end_date datetime
select @begin_date = getdate()
<這裡寫上你的語句...>
select @end_date = getdate()
select datediff(ms,@begin_date,@end_date) as '用時/毫秒'
2:下面這種方法比較全面,將執行每個語句時采取的步驟作為行集返回,通過層次結構樹的形式展示出來
復制代碼 代碼如下:
set statistics profile on
set statistics io on
set statistics time on
go
<這裡寫上你的語句...>
go
set statistics profile off
set statistics io off
set statistics time off