Wrox Programmer Forums
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 1st, 2007, 04:14 AM
Authorized User
 
Join Date: Nov 2006
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Somesh
Default Insert multiple row in server.

Hi all

I want to know that if there is any procedure to insert multiple rows in to the table of a database using stored procedure. See I am not interested to insert through a loop or using PL/SQL. just I want to know except these if there is any other procedure or not?

I found the following lines from a book that's why I am asking.


The basic INSERT statement adds one row at a time to a
table. Variations of the basic INSERT statement enable you to add multiple rows by selecting
data from another table or by executing a stored procedure.



If you know please send me the procedure.

With Regards

Somesh Chatterjee
__________________
somesh chaterjee
 
Old June 1st, 2007, 08:03 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can write a multi row insert like this:

INSERT INTO MyTable (field list...)
SELECT fieldlist... FROM MyOtherTable

This will add all the SELECTed rows to the table. Of course, this requires that the data already exists in another table.

Although I have never tried, I assume the same behavior applies when you use the execution of a SPROC as the "SELECT" source instead of a regular SELECT statement.

You want to add multiple records from data generated by the application, the only solution is to call an insert or sproc repeatedly. You could use a DataTable and DataAdapter to execute the update of the data (updating changed records and/or inserting new ones) but internally, I imagine this just calls the InsertCommand repeatedly.

Ultimately, there is no syntax in T-SQL that permits the passing of a row array to a single insert command apart from those described above.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Row in Database monika.vasvani ASP.NET 1.0 and 1.1 Professional 1 November 18th, 2006 05:17 AM
insert multiple record in sql server annie_stwg ASP.NET 2.0 Basics 4 September 19th, 2006 08:56 AM
Insert Multiple Record in SQL Server in Once lauhong28 SQL Server 2000 1 February 24th, 2006 02:43 PM
Insert data row in SQL SERVER 2000 dimeanel ADO.NET 1 January 25th, 2006 09:32 AM
Help about insert row in SQL Server 2000 dimeanel Beginning VB 6 3 January 19th, 2006 02:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.