Hi friends,
i have one table named Proj_KitDetls in which there is a Column named Id which is Identity key & primary key.and another table named Proj_kitInvDetls in which i m saving the Identity key of Proj_KitDetls as Foreign key,
but i am not able to set the values in Proj_kitInvDetls.
example: in Proj_KitDetls tables values are set in DB like this:
Id,CTNo,Kitname,KitType,BudgetUnits
86,4,CASS30KIT90,Combo Kit,10
Proj_kitInvDetls another table has value like this:
KItd(primarykey),Id(Foreignkey),Invoice_Id,Units
16,8,3,9
the value 86 is not getting set in place of 8 in Table Proj_kitInvDetls.
need help
aamir
Loading
Aamir KhanPosted Jun 25, 2012, 3:27 AM
Posted Jun 25, 2012, 2:27 AM
Use scope_identity() to get the identity value of the ProjectKit table and store into a variable.
Use the identity variable into projectkit inventory details to insert the record.
insert into projectkit values (.......)
declare @id = scope_identiy()
insert into projectkitinventorydetails (projectuid,...) values (@id,....)
In your current case, how you're getting the identity column value?