vendredi 20 février 2015

How to update table after immediate insertion in Sql Server


Vote count:

0




I am inserting into a table with 5 rows and here after inserting every row i have to take the id and need to insert into other table.


TABLE NAME: A TABLE NAME: B


In TABLE A coloumns are : first id will get genarate and this id will be used for some other tables.


id id1 id2 id3 id4 id5


After some time Table B will get inserted with 5 rows.


TABLE B:


id 1 2 3 4 5


Now i have to update table A coloumns with


id1=1 ,id2=2,id3=3,id4=4,id5=5.


I am trying with scope identity , it is providing last row id only to me.


any body please suggest what would be the approach to achive this.


select top 5 id from table B order by 1 desc will not work to me.


insert into table B values(id1) insert into table B values(id2) insert into table B values(id3) insert into table B values(id4) insert into table B values(id5)


after all these insertions i need to update my Table A


update Table A set id1fromA=id1,id1fromA=id1,id1fromA=id2,id1fromA=id3,id1fromA=id4,id1fromA=id5


can any body suggest what would be the approach to achieve this.




Joe Taras

4,480

asked 1 min ago







How to update table after immediate insertion in Sql Server

Aucun commentaire:

Enregistrer un commentaire