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’)

Hello, nice to meet you

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

2 Comments

  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!

    Reply

Leave a Reply to Siva Cancel reply