I was trying to find the unique ID of a Smurf in my appropriately named Smurf table. ID was a GUID, so I thought I would run a query like so:
SELECT * FROM Smurf WHERE ID = ’80A17BC9-AA8C-4588-B59D-00011FD411D0′
But Gargamel thwarted me with this error:
Msg 8169, Level 16, State 2, Line 2 Conversion failed when converting from a character string to uniqueidentifier.
Bummer, my Smurfs were stuck. But luckily, the solution for my stuck Smurfs wasn’t too difficult, I just has to convert the string to a uniqueidentifier:
SELECT * FROM Smurf WHERE ID = CONVERT(uniqueidentifier,’80A17BC9-AA8C-4588-B59D-00011FD411D0′)
And there they were, in all their Smurfy goodness.