farshad Posted August 8, 2003 Posted August 8, 2003 In vb.net i am running a stored procedure in sql server 2000 the SP is something like: @Curve int . . . @Qualifier varchar(3) = NULL AS select * from table1 where curve=@Curve . . . AND Qualifier = @Qualifier Basically the question is that when i run the query like select * from table1 where Qualifier IS NULL it works and returns data but in SP when no @Qualifier is passed then it becomes select * from table1 where Qualifier = NULL when it is = null it does not return data and thoughts? thanks Quote Farshad
Administrators PlausiblyDamp Posted August 8, 2003 Administrators Posted August 8, 2003 = NULL will always return NULL. Probably the easiest way is alter the SP so that you check for NULL and act accordingly i.e. Create proc . . . . AS if @Qualifier is NULL Begin --Code to handle NULL here select * from table1 where curve=@Curve . . . AND Qualifier IS NULL End Else Begin --Non Null here select * from table1 where curve=@Curve . . . AND Qualifier = @Qualifier End Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.