Hi Guys,
Actually I'm just new in SQL Stored Procedure Programming, and just want to ask this kind of situation.
I have a two table that I needed to populate in just one click of a button.
Let's say I have Table1 and Table2. They are related to each other. But I need to populate first Table1 since it's primary id is a foreign key of Table2. Here is how I wrote it:
Thank you guys for the help!Code:CREATE PROCEDURE dbo.prEntry @Var1 INT, @Var2 VARCHAR(255) AS BEGIN INSERT INTO tblTable1 ( Field11, Field12 ) VALUES ( @Var1, @Var2 ) 'Question: What must be the next code to get the Primary Key of tblTable1, to be saved on tblTable2? INSERT INTO tblTable2 ( Field21, Field22, ) VALUES ( @Var1, @Var2 'Must be the primary key of tblTable1 )




Reply With Quote