我从字符串转换为uniqueidentifier错误时转换失败 [英] I'm getting Conversion failed when converting from a character string to uniqueidentifier error

查看:362
本文介绍了我从字符串转换为uniqueidentifier错误时转换失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面创建了查询。但由于某种原因,我从字符串转换为uniqueidentifier错误时转换失败。如果我删除where子句中的一个OR语句,那么它按预期工作。请告知我是否做错了

I have created the query below. But for some reason, I'm getting Conversion failed when converting from a character string to uniqueidentifier error. If I remove one of the OR statement in the where clause then it is working as expected. Kindly advise if I'm doing anything wrong

SELECT * from tblUsers
WHERE (isnull(@ActiveOnly,0) = 0 OR (@ActiveOnly  = 1 AND StatusCode <> 'Registered'))

推荐答案

请尝试: -



Kindly try :-

SELECT * from tblUsers
WHERE (isnull(@ActiveOnly,0) = 0 OR (convert(int,@ActiveOnly) ) = 1 AND StatusCode <> 'Registered'))


这篇关于我从字符串转换为uniqueidentifier错误时转换失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆