
September 8th, 2009, 04:48 AM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 2
Time spent in forums: 38 m 29 sec
Reputation Power: 0
|
|
|
StoredProc WHERE condition based on parameters
This seems a very naive question, but is it possible to construct different WHERE conditions based on parameters passed to a storedproc, and then to use the construced WHERE condition in the SELECT statement. For example
IF (MyParam = 'T') THEN
MyWhereCondition = 'X = 1'
ELSE
MyWhereCondition = 'X = 2'
SELECT * FROM MyTable
WHERE MyWhereCondition
I would have thought this ought to be really simple, but I cannot work out how to do it. So any help greatly appreciated!
|