declare @startTime datetime
set @startTime=getdate()
---所要执行的SQL语句
select [语句执行花费时间(毫秒)]=datediff(ms,@startTime,getdate())
set @startTime=getdate()
---所要执行的SQL语句
select [语句执行花费时间(毫秒)]=datediff(ms,@startTime,getdate())
本文介绍了一种使用T-SQL在SQL Server中测量特定查询执行时间的方法。通过设置开始时间和结束时间,并利用DATEDIFF函数计算两者之间的毫秒数,可以有效地评估SQL语句的运行效率。

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