Azure MS-SQL and uniqueidentifier from PHP


Azure MS-SQL and uniqueidentifier from PHP

此Sql命令:

INSERT INTO BRANCH (COMPANY,BRANCH,CODE,NAME) 
   VALUES('CC23E791-088D-4BC4-AC62-2BC9522584D5', 
          '6335E463-9A27-4FEC-8C79-239A574D254B', 
          '1000',
          'TheName')

总是失败并出现错误:

[Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting from a character string to uniqueidentifier.

这个命令非常有效:

select cast('6335E463-9A27-4FEC-8C79-239A574D254B' as unique identifier)
select cast('CC23E791-088D-4BC4-AC62-2BC9522584D5' as uniqueidentifier)

怎么了?

不能直接将字符串强制转换为UUID,必须提供显式强制转换才能使其工作。在大多数编程语言中,这相当于缩小了演员阵容。