turnstyle (sc***@turnstyle.com) writes:
I'm trying to run a select where a
uniqueidentifier/GUID equals a hex, but I don't seem to be getting
matches.
For example, this query returns the expected record:
select * from items where itemGUID =
'{11111111-2222-3333-4444-555555555555}'
But this one does not:
select * from items where itemGUID = 0x11111111222233334444555555555555
This is because the bytes are rearranged in the textual representation.
Here is an example that works:
CREATE TABLE t (guid uniqueidentifier NOT NULL)
INSERT t (guid) VALUES ('35ADD319-FEA5-443B-8628-0FD8588BE6DA')
SELECT * FROM t
SELECT * FROM t WHERE guid = 0x19D3AD35A5FE3B4486280FD8588BE6DA
go
DROP TABLE t
That is, in the first three groups, the byte order should be reversed.
So, yes, you can do it. Question is only: should you?
--
Erland Sommarskog, SQL Server MVP,
es****@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp