i have two temp tables containing thousand of records. following are the table structures.
#TmpCity
ID | CityName
1 | test
#Location
ID | LocationName
1 | abc
2 | xyz
3 | etc
i have 2 physical tables City and Location with same schema, where as Location Table contains a foreign key CityID which will be auto incremented primary key of city table. i need to add data from #tmpCity to City Table and #tmpLocation to Location Table.
i can not use INSERT INTO as for each City record inserted i have to insert location record for that city with a scopeIdentity, due to huge number of record i want to avoid row by row operation like loop or cursor. what is the best approach to achieve this.