电竞比分网-中国电竞赛事及体育赛事平台

分享

SQL Server如何查看SQL語句的執(zhí)行時(shí)間

 yuelianga 2011-01-02

SQL Server如何查看SQL語句的執(zhí)行時(shí)間

http://database.51cto.com  2010-09-06 13:17  tzp_8  博客園  我要評(píng)論(0)
  • 摘要:SQL Server中比較簡單的查詢SQL語句執(zhí)行時(shí)間方法,供您參考,希望對(duì)您能夠有所幫助。
  • 標(biāo)簽:SQL Server  語句

SQL Server數(shù)據(jù)庫中,如何才能查看SQL語句的執(zhí)行時(shí)間呢?本文將為您介紹查詢方法,供您參考,希望對(duì)您能夠有所幫助。

下面這種是SQL Server中比較簡單的查詢SQL語句執(zhí)行時(shí)間方法,通過查詢前的時(shí)間和查詢后的時(shí)間差來計(jì)算的:

declare @begin_date datetime
declare @end_date datetime
select @begin_date = getdate()
<這里寫上你的語句...>
select @end_date = getdate()
select datediff(ms,@begin_date,@end_date) as '用時(shí)/毫秒'
 

2:下面這種方法比較全面,將執(zhí)行每個(gè)語句時(shí)采取的步驟作為行集返回,通過層次結(jié)構(gòu)樹的形式展示出來

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

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多