HI SQL Gurus,
I'm trying to pass the parameter value depends on the user choice i.e.
IF 1 Do WHERE X
IF 2 Do WHERE Y
IF 3 Do WHERE Z
use the following condition
WHERE SiteDeleted <> 1 --Active Contracts AND ( (@ContractStatus = 1 AND tblContractSite.DateActive <= GetDate() AND (tblContractSite.DateInActive IS NULL OR tblContractSite.DateInActive > GetDate())) --InActive Contracts OR (@ContractStatus = 2 AND tblContractSite.DateInActive < GetDate()) --Active and InActive Contracts** OR (@ContractStatus = 3 AND 1=1) )
@ContractStatus Int = 1,
So if the @ContractStatus =1 , use the condition its work fine
When I pass the @ContractStatus = 2 it doesn't work message prompt "Commands completed successfully"
When I pass the @ContractStatus = 3 it doesn't work either message prompt "Commands completed
It may be Bracketes/Paranthesis or making silly mistake.
Thanks for your help in advance