Subject | Using IN predicate in stored procedure |
---|---|
Author | Winston |
Post date | 2005-05-13T00:45:24Z |
I have been creating stored procedures using the FOR - SELECT - DO
constructs but find it sometimes slow for large databases (for schools).
What I discovered to be faster is incorporating the IN predicate in
joined queries when the key fields to select are known and limited to
a few values ( e.g. -
SELECT a.* FROM studentTable a INNER JOIN ..... WHERE a.studentId IN
(1009,2220,5678) AND ....
I want to do the same thing this time in stored procedures. I tried
to select the values in a first query but can't get the second query
using the IN predicate to work. I've used a string variable to store
the values selected in the first query and feed it into the IN clause.
How can I implement this?
Can anyone help me with this? Thanks
constructs but find it sometimes slow for large databases (for schools).
What I discovered to be faster is incorporating the IN predicate in
joined queries when the key fields to select are known and limited to
a few values ( e.g. -
SELECT a.* FROM studentTable a INNER JOIN ..... WHERE a.studentId IN
(1009,2220,5678) AND ....
I want to do the same thing this time in stored procedures. I tried
to select the values in a first query but can't get the second query
using the IN predicate to work. I've used a string variable to store
the values selected in the first query and feed it into the IN clause.
How can I implement this?
Can anyone help me with this? Thanks