Sql query, selection by unique identifier gives - Error converting varchar data type to uniqueidentifier

How to select a column of type uniqueidentifier when I have a pointer?

I tried to do the following:

SELECT * FROM MyTable WHERE id = '442402e-207d-b012-4b60-005056c00123' and SELECT * FROM MyTable WHERE id = '{442402e-207d-b012-4b60-005056c00123}' 

Both give me the same error: Error converting varchar data type to uniqueidentifier.

+8
sql sql-server
source share
2 answers

The first request is fine, but there is no digit in the first part of the GUID, it should contain 8 digits, not seven .... something like this:

 SELECT * FROM MyTable WHERE id = '71494DD6-90FB-417D-B9E2-28F34103C039' 
+15
source share

The first section is missing a number

4067876A-E3C3-4A3D-B2D3-E879474168C6 - valid GUID
442402e-207d-b012-4b60-005056c00123 not

+3
source share

All Articles