lpatnaik
Programmer
- Jul 11, 2002
- 53
Hi,
I need a list of IDs in the where clause of my sql query which is encapsulated in my stored proc. Ex:
....
select * from table1 where col1 in ('a','b','c'....)
...
These values ('a','b','c'....) can be fetched from a dynamic select query whose where clause I am sending as a paremeter to the proc. Ex:
exec('select col1 from table1' + @whereCondition)
The problem i am facing is that I cannot use exec within a select query. I also tried with a user defined function in order to return a table with the values. In that also, since I have to use the exec statement, the insert exec statement isnt working.
I am stuck with this @wherecondition as the client does not want to change the interface which sends it to the proc. He wants all changes to be done only on the procs.
Please advice.
regards
LP
I need a list of IDs in the where clause of my sql query which is encapsulated in my stored proc. Ex:
....
select * from table1 where col1 in ('a','b','c'....)
...
These values ('a','b','c'....) can be fetched from a dynamic select query whose where clause I am sending as a paremeter to the proc. Ex:
exec('select col1 from table1' + @whereCondition)
The problem i am facing is that I cannot use exec within a select query. I also tried with a user defined function in order to return a table with the values. In that also, since I have to use the exec statement, the insert exec statement isnt working.
I am stuck with this @wherecondition as the client does not want to change the interface which sends it to the proc. He wants all changes to be done only on the procs.
Please advice.
regards
LP