Hi all,
I have a question that I hope that you may be able to assist with.
I have a stored procedure and in it over 52 SELECT statements are executed but each SELECT uses the table value in the WHERE clause.
for instance:
SELECT a.CheckID, a.test1, a.test2, a.test3 from Test1 a where a.CheckID = @PassedID
SELECT b.CheckID, b.testb1, b.testb2, b.testb3 from Test2 b where b.CheckID = @PassedID
.
.
.
over 50 times.
This is all in an SP.
Now, I know I could probably to this by a JOIN. But there would be one SELECT with the JOIN being there over 50 times.
Is there a better way of doing this?
For instance would creating a temporary table, then do a SELECT INTO that table for like the first 6, then have it call another SP that does an UPDATE into that temporary table with the next 6, then another SP that does an UPDATE into that temporary table with the next 6, and so on.
Or just leave it the way it is? (It's relatively new but I want to address any issues before anything would happen.)
Or does anybody have any other suggestions?
Any information would be greatly appreciated.
Thanks
I have a question that I hope that you may be able to assist with.
I have a stored procedure and in it over 52 SELECT statements are executed but each SELECT uses the table value in the WHERE clause.
for instance:
SELECT a.CheckID, a.test1, a.test2, a.test3 from Test1 a where a.CheckID = @PassedID
SELECT b.CheckID, b.testb1, b.testb2, b.testb3 from Test2 b where b.CheckID = @PassedID
.
.
.
over 50 times.
This is all in an SP.
Now, I know I could probably to this by a JOIN. But there would be one SELECT with the JOIN being there over 50 times.
Is there a better way of doing this?
For instance would creating a temporary table, then do a SELECT INTO that table for like the first 6, then have it call another SP that does an UPDATE into that temporary table with the next 6, then another SP that does an UPDATE into that temporary table with the next 6, and so on.
Or just leave it the way it is? (It's relatively new but I want to address any issues before anything would happen.)
Or does anybody have any other suggestions?
Any information would be greatly appreciated.
Thanks