SQLSERVER database

0

Good day for all, I need to make an insert in two tables at once, these tables are related to a cambo id in table one and is autoincrementable and in table two is the same cambo (idtabla1) is the foreign, my question is how do I keep the autoincrementable in table one from table two if I do not know it and I want to save it as a transaction?

    
asked by Cristian Villalba 25.09.2018 в 01:01
source

1 answer

0

Well try to make these two lines, if you add them to a much better stored procedure:

Insert into table1 values (correlative1.nextval, id); Insert into table2 values (correlative2.nextval, id, correlative1.currval);

In this way in table2 you insert the value of the correlative of table1

Greetings

    
answered by 26.09.2018 в 04:53