方法一:
declare @d datetime
set @d=getdate()
select * from authors where au_fname='dirk'
select 执行时间=datediff(ms,@d,getdate())
方法二:
set statistics time on
select * from authors where au_fname='dirk'
set statistics time off
本文介绍了两种不同的方法来测量SQL查询的执行时间。方法一使用了声明变量和DATEDIFF函数来计算执行时间,方法二则利用了SET STATISTICS TIME命令来显示查询计划的执行时间详情。这些技巧有助于开发者更高效地评估和优化SQL查询性能。
方法一:
declare @d datetime
set @d=getdate()
select * from authors where au_fname='dirk'
select 执行时间=datediff(ms,@d,getdate())
方法二:
set statistics time on
select * from authors where au_fname='dirk'
set statistics time off

被折叠的 条评论
为什么被折叠?