最佳答案
一个我不能控制模式的表包含一个定义为 varchar (50)的列,该列以‘ a89b1acd95016ae6b9c8aabb07da2010’(无连字符)的格式存储惟一标识符
I want to convert these to uniqueidentifiers in SQL for passing to a .Net Guid. However, the following query lines don't work for me:
select cast('a89b1acd95016ae6b9c8aabb07da2010' as uniqueidentifier)
select convert(uniqueidentifier, 'a89b1acd95016ae6b9c8aabb07da2010')
and result in:
Msg 8169, Level 16, State 2, Line 1 Conversion failed when converting from a character string to uniqueidentifier.
使用带有连字符的唯一标识符的相同查询可以正常工作,但数据不以该格式存储。
Is there another (efficient) way to convert these strings to uniqueidentifiers in SQL. -- I don't want to do it in the .Net code.