sql server - How to Return All records if Filter is NULL (Empty) -
i have report shows purchase indents on period of time created indentor. here, @name parameter used filter indentor. but, problem is, if @name parameter blank report returning null records. want show report indentors if nothing selected in @name filter. below query. i'm new sql.
select inh.no_, inh.[approved date], inh.indentor, inl.no_ itemcode, inl.description, inl.description2, inl.req_quantity, inl.[unit of measure], pl.[document no_], ph.[order date], pl.quantity orderedquantity, pl.[quantity received] [company$indent header] inh inner join [company$indent line] inl on inh.no_ = inl.[document no_] inner join [company$purchase line] pl on inl.[document no_] = pl.[indent no_] , inl.[line no_] = pl.[indent line no_] inner join [company$purchase header] ph on pl.[document no_] = ph.no_ (inh.indentor = @name) , (inl.no_ <> '') , (inh.[approved date] between @startdate , @enddate) order itemcode
how query build. code? because leave out (inh.indentor = @name) following piece where (inh.indentor = @name) and if @name empty. guess there no condition in sql whether want take account condition in where clausule or not, correct me if wrong.
Comments
Post a Comment