How to set a DateTime variable in SQL Server 2008?

前端 未结 10 1884
暗喜
暗喜 2020-12-30 20:15

SQL Server 2008 is not doing what I expected with DateTime. It doesn\'t let me set DateTime variables, no matter what date format I use.

Wh

10条回答
  •  自闭症患者
    2020-12-30 20:52

    The CONVERT function helps.Check this:

    declare @erro_event_timestamp as Timestamp;
    set @erro_event_timestamp = CONVERT(Timestamp,  '2020-07-06 05:19:44.380',  121);
    

    The magic number 121 I found here: https://www.w3schools.com/SQL/func_sqlserver_convert.asp

提交回复
热议问题