SQL Server | Convert Varchar to UniqueIdentifier

There are 2 ways to Convert a string to a UniqueIdentifier (GUID) in SQL Server:

SELECT CAST(‘449141d9-86c9-449d-be2c-1f171b4f4567’ as UNIQUEIDENTIFIER)

SELECT CONVERT(UNIQUEIDENTIFIER, ‘449141d9-86c9-449d-be2c-1f171b4f4567’)

Categories

2 Responses

  1. Hi, I have a question.
    Want to know which one will perform better when converting varchar to uniqueidentifier OR nvarchar to uniqueidentifier? Thanks in advance!

Leave a Reply

Your email address will not be published. Required fields are marked *