473,668 Members | 2,759 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 16329
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
7064
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
6165
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
1889
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
4973
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
188308
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
28081
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
2536
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
5652
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
5016
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
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8797
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
8583
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
8656
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5681
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.