从字符串转换为 uniqueidentifier 错误

Converting from a character string to uniqueidentifier error

我做错了什么。当我运行

insert into tblconfig_extensiongroupMembers (FKExtension,FKextensiongroup)
    values ('C7972F9-56SC-951S-CSRS-15VDAR4895W2','F15745S4-R512-45RD-84S0-5DSWW16A526W') 

从字符串转换为 uniqueidentifier 时出现以下错误 conversion failed?

问题出在你的字符串格式上,应该是MSDN中指定的格式:

By converting from a string constant in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, in which each x is a hexadecimal digit in the range 0-9 or a-f. For example, 6F9619FF-8B86-D011-B42D-00C04FC964FF is a valid uniqueidentifier value.

第一部分有 8 个字符的工作示例:

CREATE TABLE #tmp   (id UNIQUEIDENTIFIER)

INSERT INTO #tmp
        ( id )
VALUES  ( '12345678-1234-1234-1234-123456789012')

SELECT * FROM #tmp

DROP TABLE #tmp

数值比较:

C7972F9-56SC-951S-CSRS-15VDAR4895W2  -- (Bad format)
12345678-1234-1234-1234-123456789012 -- (Good format)

除了其他人提到的长度问题,该值应该只包含十六进制数字。

您的值包含无效字符,例如SRWV