473,320 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Multiple table value insertion with single Stored procedure

Hi Every one !

I need to insert a set of values which are passed thru the parameter ,Below is the code to do the Single table insertion , Now I need to do multiple table insertion ie, to insert values with the addtional parameter in another table but using the same stored procedure !!

CREATE procedure [dbo].[Pro_SIDN]
@SID int,
@FirstName varchar(10),
@MiddleName varchar(10),
@LastName varchar(10),
@FullName varchar(10),
insert into tableA(SID,Firstname,Middlename,Lastname,Fullname)
values (@SID,@FirstName,@MiddleName,@LastName,@FullName)

Kindly provide me with some sample code ASAP !
Thanks in advance !
Jul 10 '07 #1
2 2568
Motoma
3,237 Expert 2GB
Please do not post questions to the Articles section of the site. I have moved your question to the appropriate forum; hopefully you will find more help there.
Jul 11 '07 #2
Infide
28
Hi Every one !

I need to insert a set of values which are passed thru the parameter ,Below is the code to do the Single table insertion , Now I need to do multiple table insertion ie, to insert values with the addtional parameter in another table but using the same stored procedure !!

CREATE procedure [dbo].[Pro_SIDN]
@SID int,
@FirstName varchar(10),
@MiddleName varchar(10),
@LastName varchar(10),
@FullName varchar(10),
insert into tableA(SID,Firstname,Middlename,Lastname,Fullname)
values (@SID,@FirstName,@MiddleName,@LastName,@FullName)

Kindly provide me with some sample code ASAP !
Thanks in advance !
I'm not exactly sure what you're trying to accomplish. But this may get you started.

Expand|Select|Wrap|Line Numbers
  1. create proc usp_Example
  2. (@Value1 varchar(50),@Value2 varchar(50))
  3. AS
  4. BEGIN
  5.  
  6. DECLARE @ParentTablePrimaryKey INT
  7.  
  8. Insert into ParentTable(Column1)
  9. values(value1)
  10.  
  11. set @ParentTablePrimaryKey = @@IDENTITY
  12.  
  13. Insert into ChildTable(Column1,fk_ParentTableID)
  14. values(@value2,@ParentTablePrimaryKey)
  15.  
  16. END
  17.  
  18.  
You can do as many selects, inserts, deletes and updates as you want in a stored proc. I've seen stored procs over 1000 lines long. If you are working with a relational database with identity columns you will need to grab the identity ID that is auto generated when you insert with the @@Identity.

I think this is what you are going after. If not please provide us with some more details.
Jul 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: JB | last post by:
To anyone that is able to help.... What I am trying to do is this. I have two tables (Orders, and OrderDetails), and my question is on the order details. I would like to set up a stored...
3
by: Gaz | last post by:
I have a table which has 10 columns which make up the secondary key. 1 or more of these columns can be set but the remaining columns in the secondary key will be null. For example : id k1 k2...
1
by: Sylesh Nair | last post by:
could anyone give me a possible solution for a Windows Service (in C#) listening to a table in a database for insertion or updation. thanks
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
2
by: Diego | last post by:
Hi everybody! I'm using DB2 PE v8.2.3 for linux. I've defined a database with the following schema: ANNOTATION(ID,AUTHOR,TEXT) ANNOTATION_BOOK(ANNOTATION_ID,OBJECT_ID)...
5
by: Wael | last post by:
Hi, I have the following stored procedure that does some processing and puts the result in a temporary table. I tried several things that procedure to display output that I can access with...
2
by: =?Utf-8?B?VGVycnk=?= | last post by:
I have coded multiple select statements in a single stored procedure, and when I execute this procedure on SQL Server Management Express, I correctly get multiple result sets. But, if I try to add...
4
by: =?Utf-8?B?TWFkaXNvbg==?= | last post by:
Hi all, Could I use the sqldatasource with stored-procedure to return multiple recordset? I did not want to have any sqldatasourec in the one page just to return the record back to...
6
by: BostonNole | last post by:
I am using SQL 2000 and VB.NET (VS 2005). I have three stored procedure: sp_A, sp_B and sp_C I need to be able to call sp_A once and sp_B and sp_C 1 to n number of times all within a single...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.