Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 March 30th, 2006, 06:13 AM
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Deepak Chauhan
Default Insert multiple records using one SQL Query.

Hi All,

I've quite a strange requirement to insert multiple records into a table.
I have some numbers say 14,32,3,5,7,811,43,45 which i want be inserted into a table T1 with one column N1

but i want all these values to be inserted as different records records in one go without using any looping .

I know this can be done using the INSERT ... SELECT ... Statements.
or slightly different way.

But not sure on how exactly it can be done.

On a slightly different requirement I want a way to get these values in the form of records without using any table.


I mean i need a select statement on the values 1,3,65,22,65,77,33

something like Select * from (1,3,65,22,65,77,33)

and the result be displayed in the form

(No Column Name)
----------------
1
3
65
22
65
77
33

Is it possible.

I know some experts out there can help me do these things.

I will appreciate any help on this

Thanks,
Deepak Chauhan
XpertGuys.com




 
Old March 31st, 2006, 01:36 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You need a individual Insert statement for each value you want to insert.

Quote:
quote:
On a slightly different requirement I want a way to get these values in the form of records without using any table.
Not sure what you mean by this.

You can use inte IN clause
Select <some col>
from <some table>
where <some col> IN (1,3,65,22,65,77,33)
 
Old March 31st, 2006, 11:32 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hei!

Is this of any help?

Set MyConn = CreateObject("ADODB.Connection")

MyConn.Open "your name for the cnnection-string"
    Set RS = MyConn.Execute("SELECT * FROM tabname WHERE anyField = '" & aVar & "'")


If Not RS.EOF then
MyConn.Execute "UPDATE Produkt SET fieldName = '" & aVar & "' WHERE anyField = '" & anyVar & "'"

    Else
    End if

    MyConn.Close
    Set MyConn = Nothing

    response.redirect "anyPage.asp"


Regards from

grstad


 
Old April 12th, 2006, 07:43 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

... sorry, that one must have been directed to the wrong page!








Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert multiple records from form lorirobn Access 2 April 9th, 2007 03:08 PM
Insert multiple records mateenmohd Access 13 November 2nd, 2004 09:15 AM
insert multiple records mateenmohd Classic ASP Basics 19 October 18th, 2004 01:22 AM
Insert multiple records in a Inner Join Table rylemer Access VBA 0 July 19th, 2004 03:54 PM
Best way to insert multiple records koo9 ADO.NET 2 June 28th, 2003 08:37 PM





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