How do you convert VARCHAR to TIMESTAMP in MSSQL?

前端 未结 3 1047
刺人心
刺人心 2021-01-05 13:47

You\'d like to call a stored proc on MS SQL that has a parameter type of TIMESTAMP within T-SQL, not ADO.NET using a VARCHAR value (e.g. \'0x0000000002C490C8\').

Wha

3条回答
  •  臣服心动
    2021-01-05 14:07

    Since timestamp is compatible with varbinary the solution will be this in SQL Server 2008:

    declare @hexstring varchar(max);
    set @hexstring = '0xabcedf012439';
    select CONVERT(varbinary(max), @hexstring, 1);
    
    set @hexstring = 'abcedf012439';
    select CONVERT(varbinary(max), @hexstring, 2);
    

    Reference. MSN Blogs

提交回复
热议问题