How to print GETDATE() in SQL Server with milliseconds in time?

前端 未结 7 562
情书的邮戳
情书的邮戳 2021-02-03 16:49

I want to print GETDATE() in SQL Server 2008, I need the time with milliseconds (this is for debugging purpose - to find sp\'s execution time )

I find this Difference

7条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 17:19

    First, you should probably use SYSDATETIME() if you're looking for more precision.

    To format your data with milliseconds, try CONVERT(varchar, SYSDATETIME(), 121).

    For other formats, check out the MSDN page on CAST and CONVERT.

提交回复
热议问题