Thursday, May 19, 2011

How to show time cost for one query in T-SQL?


      DECLARE @starttime DATETIME2 = SYSDATETIME(), @alltime datetime2 = sysdatetime();
      DECLARE @finishtime INT;

/* Your query is in here */

      SELECT @finishtime = DATEDIFF(millisecond, @starttime, SYSDATETIME());
      PRINT '(ms): ' + CONVERT(VARCHAR, @finishtime)

No comments:

Post a Comment