473,402 Members | 2,053 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,402 software developers and data experts.

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 7053
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*******@tampabay.rr.com> wrote in message
news:97**************************@posting.google.c om...
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*******@tampabay.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_preparedocument 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*******@tampabay.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

4
by: Raj Kotaru | last post by:
Hi, In sqlplus, I can insert a single row using: insert into employee (name, salary, hiredate) values ('xyz', '86378', sysdate); Is there a modification of the insert command that will...
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...
1
by: Scott Chapman | last post by:
I am working with Python (psycopg). I have HTML with embedded Python that I'm inserting into a database and it could contain any character. Single quotes, at least, must be escaped (to two...
0
by: a | last post by:
I've read and split a delimited text file into a dataset. It looks fine in a datagrid (5 columns and 5,000 rows), but I've been trying, without success, to then insert the resulting dataset called...
2
by: a | last post by:
NEW Post Here's my best guess at how to insert this dataset.... the code runs, but no new records are added to the sql table. I've read and split a delimited text file into a dataset. It...
9
by: Mr Newbie | last post by:
HI People, Thanks to all who helped me earlier on the subject of @@IDentity. However, I seem to have hit another snagette! My DataSet contains two tables from the SQL Server. lets say Master...
5
by: JSParker1 | last post by:
Summary: Maximum number of records per second that can be inserted into SQLServer 2000. I am trying to insert hundreds (preferably even thousands) of records per second in to SQLServer table...
9
by: TC | last post by:
I need to design a system which represents multiple "projects" in SQL Server. Each project has the same data model, but is independent of all others. My inclination is to use one database to store...
0
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...
4
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.