SQL执行时间计算-常用的两种方法

1. 自定义的

declare @watch datetime;

set @watch=getdate();

select * from xxx;

select datediff(ms,@watch,getdate()) as elapsedTime;

2. 系统提供的

set statistics time on
--set statistics io on
select * from table
--set statistics io off
set statistics time off

结果输出在消息窗口里,如:

SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 17 ms.
posted @ 2021-11-05 22:35  QAQhong  阅读(368)  评论(2编辑  收藏  举报