sql - How to use IF Else in store procedure? -


i trying execute select query id parameter, if id empty want rows, otherwise row contains id, far, have created store procedure,

if(@custid = null)   begin    select * tblcustomer   end else   begin    select * tblcustomer custid=@custid   end 

when executing query id, getting result when passing, not getting result. what's correct way this?

null handled differently other values, need use

if (@custid null) 

your current code of if(@custid = null) evaluate false, else case executed regardless of pass @custid. this article goes more detail how handle null values:


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -