Sql query, selecting on unique identifier gives - Error converting data type varchar to uniqueidentifier
How do I select a column of type uniqueidentifier when I have a guid?
I've tried doing following:
SELECT 开发者_Python百科* FROM MyTable WHERE id = '442402e-207d-b012-4b60-005056c00123'
and
SELECT * FROM MyTable WHERE id = '{442402e-207d-b012-4b60-005056c00123}'
Both give me same error: Error converting data type varchar to uniqueidentifier.
The first query is ok, but you are missing a digit on the first part of the GUID, it should have 8 digits, not seven....something like this:
SELECT * FROM MyTable WHERE id = '71494DD6-90FB-417D-B9E2-28F34103C039'
You are missing a digit in the first section
4067876A-E3C3-4A3D-B2D3-E879474168C6
is a valid GUID
442402e-207d-b012-4b60-005056c00123
is not
精彩评论