How to use the original Guid in the SQL statement instead of the little endian one?

China☆狼群 提交于 2019-12-05 11:54:41

If you want to easily compare to the original without converting then store it as text. It'll take more storage space and will be slower to read/write/compare, but it'll be more human readable.

I'm having similar frustrations and am experimenting with a querying tool to do conversion for me.

For now I get by with something like the below.

select quote(SomeGuid) from MyTable where name = 'Some Name'

Which returns

X'12A0E85D8175514DA792EC3D9A8EFCF7'

Formatting the original guid and comparing to the above:

5DE8A01275814D51A792EC3D9A8EFCF7 -- original no dashes, uppercase 12A0E85D8175514DA792EC3D9A8EFCF7 -- quote(Guid)

I can get away with querying a partial Guid for filtering purposes.

Note % on the right side too - value is quoted

select * from MyTable where quote(SomeGuid) like '%A792EC3D9A8EFCF7%'
Grammy

Try this:

INSERT INTO [Table1] ([UID]) VALUES ('{57A00F30-1531-0D40-81AD-4ADEF3EBDB5E}');

I always do in this way, didn't find any problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!