sql - Can I use a report paramater as a section of the WHERE clause -


i have query runs great

where (customer in (@cust)) 

and @cust customer or multiple list of customers

what want add and more in optional parameter

no: @expiring = " " 

or

yes: @expiring = " , getdate() >= dateadd(d,[expirywarning],[expirydate]) " 

then want add end of where , have second part if it's chosen dropdown yes or no can show whole list of customers or ones expiring in report.

where (customer in (@cust)) @expiring 

but seeing error when try run report

that there's error near @expiring

any insight? i've been searching day, possible?

you need change clause take @expiring account this.

where customer in (@cust)     , (@expiring='no' or getdate() >= dateadd(d,[expirywarning],[expirydate])) 

so if @expring 'no' part of clause returns true. if expiring = 'yes' date criteria must true else part return false.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -