首页 > 其他 > 详细

字段类型(uniqueidentifier)问题

时间:2020-01-16 10:49:12      阅读:73      评论:0      收藏:0      [点我收藏+]

环境:SQL 2016;

语句 select * from A where PID=JoID

上述查询语句中的Where PID=JoID条件中PID的字段类型为varchar(50)而JoID的字段类型为uniqueidentifier,该写法在升级之前的(SQL2012)库上没有问题,但在新库(SQL2016)中会报错(Conversion failed when converting from a character string to uniqueidentifier)。只需对字段(uniqueidentifier)做个类型转换即可(PID=cast(a.JoID as varchar(36))),但由于PID字段中存储的数据带“{}”所以需将上述条件改为where substring(PID, 2, len(PID)-2) = cast(JoID as varchar(36))

技术分享图片

字段类型(uniqueidentifier)问题

原文:https://www.cnblogs.com/adsoft/p/12199814.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!