Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


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)


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
Posted
Updated 13-Nov-10 9:46am
v2

1 solution

Try:
AND (@BookName IS NULL OR o.BookName = @BookName )

sometimes it can helps
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900