Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i have 3 tables in data set
dtPurchase, dtPurchaseProduct and dtPurchaseProductExp

dtPurchase is parent table of dtPurchaseProduct and dtPurchaseProduct is parent table of dtPurchaseProductExp.

i want to insert these rows to database talbes respectively.

all primary key columns are sql server autogenerated id columns.
Posted
Updated 23-Jul-13 19:08pm
v2

1 solution

Insert into first table and get its primary key using SCOPE_IDENTITY which will return you the last generated identity value within your current scope.

SQL
SELECT SCOPE_IDENTITY AS NewID
 
Share this answer
 
Comments
deva936 24-Jul-13 23:36pm    
yeah i have used it
it is fine with 2 tables but can't solve with 3 tables

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900