Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Farshad
  • Administrators
Posted

= 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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...