Other way than SP? - 08-28-2009 , 01:57 PM
The SP opens a cursor and loop a product table on a DB and generates the
records that was read to other 3 tables on other DB...
Loop "Select * from DB.Product"
@iID = @iID + 1
Insert into otherDB.Product(ID,Description,otherfields...) values select
@iID, description, ..., ...
Insert into otherDB.ProductStock(ID,QttValue,otherfields...) values
select @iID, description, ..., ...
Insert into otherDB.AnotherTable(ID,otherfields...) values select @iID,
etc, ..., ...
I need the same ID for the record that will be inserted on the others
Is there other way instead using SP?
MS SQL 2000
Re: Other way than SP? - 08-28-2009 , 02:53 PM
"Paulo" <eris_paulo (AT) terra (DOT) com.br> wrote
If you insert everything into a temporary table, possibly allocating the id
through an identity. You can then have a know set of ids and you wouldn't
need to loop just use insert...select. Alternatively if you have all the
information in the first table you could try a trigger and use the inserted