Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 A better way, kinda like life

Author  Topic 

Vivaldi
Constraint Violating Yak Guru

298 Posts

Posted - 2001-07-26 : 07:48:26
Well Sql Jedi's,

I have a Basic Question.
I have three tables.

Table1
id | name
Table2
id |table1.id|name
Table3
id | table2.id | name

2 relates to 1, 3 relates to 2.

I am writing a stored proc to run the copy based on Table1's ID. Then "cascade" through all the applicable records in table2 and the applicable records in table3.

I basically just want to select the data out of the table, alter it a little (add some text) and re insert it into the same table as a "copy") for each record that relates to the ID passed in.

My thoughts are filled with lots of cursors.

[In pseudo]
Select Table1 REcord into cursor
Insert Copy of Table1

Select TAble2 records for table1.id with cursor
insert within loop

.... same for table3.

IS There a BETTER way?



Composing temporary solutions to permanent problems
   

- Advertisement -