HiI'm writing a search storedprocedure.I want when user enter Creditor it comes into the storedprocedure else I don't want to involve it in my storedprocedure.this is the storedprocedure that I have written:@docdtl nvarchar(50)=null, @facnum nvarchar(50)=null, @creditor nvarchar(50)=null, @debtor nvarchar(50)=null, @office intASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; select * from [document] where OfficeID=@office and (FacNum=''+@facnum+'''')UNIONselect * from [document] where OfficeID=@office and (DocDetails=''+@docdtl+'''')UNIONselect * from [document] where OfficeID=@office and Creditor=CASEwhen Creditor<>'' then (convert(nvarchar(50),@creditor))Else NullENDselect * from [document] where OfficeID=@office and (Creditor=convert(nvarchar(50),@creditor))UNIONselect * from [document] where OfficeID=@office and (Debtor=convert(nvarchar(50),@debtor))END
but when I run it and don't enter the Creditor it shows the records that have a Ceditor with value 0.what shuld I do?Sara Dajer