473,903 Members | 3,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL 2000: Inserting multiple rows into a single table

JB
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 procedure that essentially inserts in the orders
table the mail order, and then insert multiple orderdetails within the
same transaction. I also need to do this via SQL 2000. Right now i
have "x" amount of variables for all columns in my orders tables, and
all Columns in my Order Details table. I.e. @OColumn1, @OColumn2,
@OColumn3, @ODColumn1, @ODColumn2, etc... I would like to create a
stored procedure to insert into Orders, and have that call another
stored procedure to insert all the Order details associated with that
order. The only way I can think of doing it is for the program to pass
me a string of data per column for order details, and parse the string
via T-SQL. I would like to get away from the String format, and go
with something else. If possible I would like the application to
submit a single value per variable multiple times. If I do it this way
though it will be running the entire SP again, and again. Any
suggestions on the best way to solve this would be greatly
appreciated. If anyone can come up with a better way feel free. My
only requirement is that it be done in SQL.

Thank you
Jul 20 '05 #1
3 16351
JB
I am not sure understand you. Why do you need variables for your columns?
First thought
CREATE PROC spInsert_Order
@OrderID int,
.......
........
AS
BEGIN TRAN
INSERT INTO Orders VALUES (@OrderID,...,. ..,...)
INSERT INTO Orders_Details VALUES ((@OrderID..... ......)
COMMIT
Second thought

You can create trigger for INSERT on Orders table. When you perform INSERT
statement the trigger is fired and insert appropriate data into
Orders_Details table
"JB" <JB*******@tamp abay.rr.com> wrote in message
news:97******** *************** ***@posting.goo gle.com...
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 procedure that essentially inserts in the orders
table the mail order, and then insert multiple orderdetails within the
same transaction. I also need to do this via SQL 2000. Right now i
have "x" amount of variables for all columns in my orders tables, and
all Columns in my Order Details table. I.e. @OColumn1, @OColumn2,
@OColumn3, @ODColumn1, @ODColumn2, etc... I would like to create a
stored procedure to insert into Orders, and have that call another
stored procedure to insert all the Order details associated with that
order. The only way I can think of doing it is for the program to pass
me a string of data per column for order details, and parse the string
via T-SQL. I would like to get away from the String format, and go
with something else. If possible I would like the application to
submit a single value per variable multiple times. If I do it this way
though it will be running the entire SP again, and again. Any
suggestions on the best way to solve this would be greatly
appreciated. If anyone can come up with a better way feel free. My
only requirement is that it be done in SQL.

Thank you

Jul 20 '05 #2
JB (JB*******@tamp abay.rr.com) writes:
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 procedure that essentially inserts in the orders
table the mail order, and then insert multiple orderdetails within the
same transaction. I also need to do this via SQL 2000. Right now i
have "x" amount of variables for all columns in my orders tables, and
all Columns in my Order Details table. I.e. @OColumn1, @OColumn2,
@OColumn3, @ODColumn1, @ODColumn2, etc... I would like to create a
stored procedure to insert into Orders, and have that call another
stored procedure to insert all the Order details associated with that
order. The only way I can think of doing it is for the program to pass
me a string of data per column for order details, and parse the string
via T-SQL. I would like to get away from the String format, and go
with something else.


There is no need for you to compose your string format and parse it.
Pass the string as XML instead, and use sp_xml_prepared ocument and
OPENXML to unpack it. Now you can pass many orders and their order details
if you like.


--
Erland Sommarskog, SQL Server MVP, so****@algonet. se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
You can easily pass multiple rows into a stored procedure using XML.

But I don't understand what you mean by variables for your columns.

On 27 Apr 2004 16:23:24 -0700, JB*******@tampa bay.rr.com (JB) wrote:
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 procedure that essentially inserts in the orders
table the mail order, and then insert multiple orderdetails within the
same transaction. I also need to do this via SQL 2000. Right now i
have "x" amount of variables for all columns in my orders tables, and
all Columns in my Order Details table. I.e. @OColumn1, @OColumn2,
@OColumn3, @ODColumn1, @ODColumn2, etc... I would like to create a
stored procedure to insert into Orders, and have that call another
stored procedure to insert all the Order details associated with that
order. The only way I can think of doing it is for the program to pass
me a string of data per column for order details, and parse the string
via T-SQL. I would like to get away from the String format, and go
with something else. If possible I would like the application to
submit a single value per variable multiple times. If I do it this way
though it will be running the entire SP again, and again. Any
suggestions on the best way to solve this would be greatly
appreciated. If anyone can come up with a better way feel free. My
only requirement is that it be done in SQL.

Thank you


Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7069
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 procedure that essentially inserts in the orders table the mail order, and then insert multiple orderdetails within the same transaction. I also need to do this via SQL 2000. Right now i have "x" amount of variables for all columns in my orders tables,...
5
6200
by: Arsen V. | last post by:
Hello, What is the optimal way to insert multiple rows (around 1000) from a web application into a table? The user enters multiple lines into a text box (up to 10,000). The ASP.NET application breaks that data into a string array. Each line is an item of that array. The user clicks Submit.
0
1900
by: craftit | last post by:
hi everyone, i need to insert multiple rows in a single table using Oledbdataadapter for access database all in one trip in my winform(VB.Net). i've tried the best i can.Can anyone please help me out . Thanks
4
4988
by: Joanie | last post by:
I have a form that records dates of unavailability for a worker. Based on what is entered in the simple table behind the form, many calculations take place to create employee "load" balance. Each day needs to be inserted as a separate row on the table. Right now the users enter each date as a separate row. They want to just be able to enter a range. How do I add the multiple rows from the date range entered on the form AND exclude weekends?
20
188398
by: talktozee | last post by:
Hey, everyone! Basically, I need to insert *multiple rows* into table A from table B based upon some criteria, and I need to insert some static values along with each row from table A. For example: insert into tableA (col1,col2,col3,col4,col5) values ('Cheese', 'Blue',
3
28091
Atli
by: Atli | last post by:
Hi. I've been trying to insert multiple rows into a table using a single INSERT statement in MSSQL / SQL Server 2005. I could of course cheat and have my C# code insert each row using some sort of a loop, but where is the fun in that :-) If you'r familliar with MySQL, this MySQL query would do what I am trying to do with MSSQL / SQL Server 2005. INSERT INTO UserInfo(InfoName, InfoValue) VALUES
16
2563
by: jasone | last post by:
Hi all, The system im working on currently allows the user to select a number of flowers.. click submit and whatever they clicked is passed onto the next page, i now want them to click order and each flower is inserted into the table. username - flowerid - qty - total user1 ------------ 2 ------- 1----- 1.99 user1 ------------ 3 ------- 5----- 2.55 user1 ------------ 6 ------- 1----- 0.50 i havent set up the session yet to display...
4
5662
by: edtrvl | last post by:
Hi there, I'm trying to insert multiple rows from a table format web form into multiple rows in a SQL table, (1 row for 1 row). Any help would be greatly appreciated, thanks in advance Here's the code of my page: <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="../../../Connections/BILLING.asp" --> <% FEQUIPID = Request.form("EQUIPID") ' Convert the info from the form to a string
3
5034
by: Vinda | last post by:
Hi Bytes, Using a previous question as a base Access 2000 Inserting multiple rows based on a date range. I also wanted to insert multiple rows into a table according to a date range supplied by a user (eg txtRDateStart & txtRDateEnd). The script was envisaged to be able to also gather a time and text description that would be repeated within each row. For example: The user would enter... Start Date: 13/03/2010 End Date: 17/03/2010...
0
10872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9675
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5893
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4725
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4308
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3324
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.