johnaregan
Programmer
- Mar 13, 2001
- 87
Hi
I want to be able to build a WHERE clause of an SQL statment depending on another variable in a stored procedure. This isnt T-SQL code but just to give you some idea:
select * from aTable where
col1 = 1 and
If aValue = '5' Then
col2 = 2 and
End If
If aValue = '6' Then
col3 = 3
End If
so that if aValue = 5 then the actual SQL run against the database will be
select * from aTable where
col1 = 1 and
col2 = 2
Thanks in advance
I want to be able to build a WHERE clause of an SQL statment depending on another variable in a stored procedure. This isnt T-SQL code but just to give you some idea:
select * from aTable where
col1 = 1 and
If aValue = '5' Then
col2 = 2 and
End If
If aValue = '6' Then
col3 = 3
End If
so that if aValue = 5 then the actual SQL run against the database will be
select * from aTable where
col1 = 1 and
col2 = 2
Thanks in advance