Is this Possible in sql?
-
In sql database , I have two tables named Emp_Info and Emp_Experience the structure of table is like this; Emp_Info ======== Emp_Id PrimaryKey(Auto) Emp_Name Emp_Age Emp_Experience ============== Exp_Id PrimaryKey(Auto) Emp_Id ForeignKey Exp_Detail Exp_Year . . . . ... and so on Working on a single form, All these fields have to be enterd and are saved against one button click.The Problem is how can i get the Emp_Id for Emp_Experience table to save Experince and Emp_Info paralelly.The relationship btw Emp_Info and Emp_Experience is one to many. that is, Against one Employee there may be none or many Experiences. in the scenario, i have to add Experiences first and then save the Employee? What 2 do? any guide line, help .....>? i need its stored procedure for saving Experiences. Thnx in Advance
-
In sql database , I have two tables named Emp_Info and Emp_Experience the structure of table is like this; Emp_Info ======== Emp_Id PrimaryKey(Auto) Emp_Name Emp_Age Emp_Experience ============== Exp_Id PrimaryKey(Auto) Emp_Id ForeignKey Exp_Detail Exp_Year . . . . ... and so on Working on a single form, All these fields have to be enterd and are saved against one button click.The Problem is how can i get the Emp_Id for Emp_Experience table to save Experince and Emp_Info paralelly.The relationship btw Emp_Info and Emp_Experience is one to many. that is, Against one Employee there may be none or many Experiences. in the scenario, i have to add Experiences first and then save the Employee? What 2 do? any guide line, help .....>? i need its stored procedure for saving Experiences. Thnx in Advance
Use something like, 1. Insert Into Emp_Info............ 2. Store newly created auto generated id in a local variable as, Select @newId = @@IDENTITY 3. Insert Into Emp_Experience....... and use @newId as fk here Farhan Noor Qureshi if (this == this) thow this;