uerobertson
Programmer
I am writing a stored procedure that will take in a table name and some field names and use the info from that table to update or add records to another table. I can't just use the
because an ID is retrieved from yet another table. (Not my table design - came down from higher up). My questions are these:
Can I declare a
for a
statement that uses local variables for table and field names?
i.e.
Is a
the best way to go about this?
Looking through the threads it seems that most of the time the recommendation is to use a temporary table or a view. Is there a general recommendation that can be made of
vs.
vs.
?
I am using a
because I need to go through each record individually as I am calling another procedure to do the actual updates. I am trying to keep each procedure as general as possible as each could be used for several different tables. I don't want to end up with 15 procedures that all do the same thing. Extensibility is more important than speed.
Thank you for all your help.
Ursula
Code:
UPDATE INTO
Can I declare a
Code:
CURSOR
Code:
SELECT
i.e.
Code:
DECLARE CURSOR FOR
SELECT @field1, @field2 FROM @table1
Is a
Code:
CURSOR
Looking through the threads it seems that most of the time the recommendation is to use a temporary table or a view. Is there a general recommendation that can be made of
Code:
CURSOR
Code:
#TABLE
Code:
VIEW
I am using a
Code:
CURSOR
Thank you for all your help.
Ursula