How do I only include an "and" statement in a where clause if a variable has a value in it?
How do I only include an "and" statement in a where clause if a variable has a value in it? I need to modify a real long stored procedure and I only want it to match an Id if that varibale has a value, I saw some examples of using a case statement but cant figure out how to get it working. If the variable string is empty then I want to execute the other stuff in the where clause otherwise I want to retrieve back a specific record to match the variable.
Microsoft SQL Server 2008Microsoft SQL Server 2005
Imran Javed Zia
8/22/2022 - Mon
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!