sql存储过程参数问题 [英] sql stored procedure parameter problem
本文介绍了sql存储过程参数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好-
我的一个SP遇到这个奇怪的问题.
我有一个SP,参数之一是nvarchar类型.
并且我声明了该参数,我也包括了值,但是当我运行时,没有返回任何数据.
简短示例:
Hello -
I have this weird problem with one of my SP''s.
I have a SP and one of the parameters is nvarchar type.
and I am declaring the parameter, I am including value too, but when I am running there is no data returned.
short example:
@BookName nvarchar = null
然后在where子句中有:
Then in the where clause I have:
AND (o.BookName = @BookName OR @BookName IS NULL)
没有数据返回.
但是当我做的时候:
No data is returned.
But when I am doing:
AND (o.BookName = ''SQL Book'' OR @BookName IS NULL)
我得到了正确的结果.
只是让您知道该字段不是FK.
有什么想法可能是原因吗?
谢谢
I am getting the proper results.
Just to let you know that the field is no FK.
Any ideas what can be the reason?
Thanks
推荐答案
尝试:
AND (@BookName IS NULL OR o.BookName = @BookName )
有时会有所帮助
sometimes it can helps
这篇关于sql存储过程参数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文