Return value from a stored procedure
-
Hi, I have one stored procedure for inserting values to 5 tables at a time.So there are 5 insert statements in a single SP.Here some fields are common ie.there is customer address and sponsor address and all these addresses are stored in a single table.Firstly I insert customer details in the customer table and contact details to the contact table.Also sponsor contact addresses are stored in the contact table.How can I handle this Thanks Denny
-
Hi, I have one stored procedure for inserting values to 5 tables at a time.So there are 5 insert statements in a single SP.Here some fields are common ie.there is customer address and sponsor address and all these addresses are stored in a single table.Firstly I insert customer details in the customer table and contact details to the contact table.Also sponsor contact addresses are stored in the contact table.How can I handle this Thanks Denny
I assume you have primary key/foreign key relationships happening... if you do, use select @@IDENTITY to find the identify of the item you have inserted, so you can use it in the next insert. eg:
insert into table1(name) values('Fred')
go
insert into table2(address, nameid) select '10 Smith Street', @@IDENTITY
goI don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!
-
Hi, I have one stored procedure for inserting values to 5 tables at a time.So there are 5 insert statements in a single SP.Here some fields are common ie.there is customer address and sponsor address and all these addresses are stored in a single table.Firstly I insert customer details in the customer table and contact details to the contact table.Also sponsor contact addresses are stored in the contact table.How can I handle this Thanks Denny
-
I assume you have primary key/foreign key relationships happening... if you do, use select @@IDENTITY to find the identify of the item you have inserted, so you can use it in the next insert. eg:
insert into table1(name) values('Fred')
go
insert into table2(address, nameid) select '10 Smith Street', @@IDENTITY
goI don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!
Thanks