SQL Server: converting UniqueIdentifier to string in a case statement

后端 未结 4 1665
眼角桃花
眼角桃花 2020-12-13 05:30

We have a log table that has a message column that sometimes has an exception stack trace. I have some criteria that determines if the message has this. We do not want to sh

相关标签:
4条回答
  • 2020-12-13 05:51

    I think I found the answer:

    convert(nvarchar(50), RequestID)
    

    Here's the link where I found this info:

    http://msdn.microsoft.com/en-us/library/ms187928.aspx

    0 讨论(0)
  • 2020-12-13 06:01

    It is possible to use the convert function here, but 36 characters are enough to hold the unique identifier value:

    convert(nvarchar(36), requestID) as requestID
    
    0 讨论(0)
  • 2020-12-13 06:01

    Instead of Str(RequestID), try convert(varchar(38), RequestID)

    0 讨论(0)
  • 2020-12-13 06:03

    In my opinion, uniqueidentifier / GUID is neither a varchar nor an nvarchar but a char(36). Therefore I use:

    CAST(xyz AS char(36))
    
    0 讨论(0)
提交回复
热议问题