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 !
2 2568
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.
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. -
create proc usp_Example
-
(@Value1 varchar(50),@Value2 varchar(50))
-
AS
-
BEGIN
-
-
DECLARE @ParentTablePrimaryKey INT
-
-
Insert into ParentTable(Column1)
-
values(value1)
-
-
set @ParentTablePrimaryKey = @@IDENTITY
-
-
Insert into ChildTable(Column1,fk_ParentTableID)
-
values(@value2,@ParentTablePrimaryKey)
-
-
END
-
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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
|
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...
|
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)...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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...
| |