declare @sttime datetime
set @sttime=getdate()
print @sttime
Select * from case1219 -- 把你的sql语句放在这里
SELECT RTRIM(CAST(DATEDIFF(MS, @sttime, GETDATE()) AS CHAR(10))) AS 'TimeTaken'
或者这么写
DECLARE @t1 DATETIME;
DECLARE @t2 DATETIME;
SET @t1 = GETDATE();
Select * from dimDate ;-- 把你要查询的sql语句放在这里
SET @t2 = GETDATE();
SELECT DATEDIFF(millisecond,@t1,@t2) AS elapsed_ms;