Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 25th, 2002, 12:38 PM
Criminologist Criminologist is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 1 Criminologist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Insert w/Subselect format question

I'm working on quite a problem here.

I need to select a recordset worth of data from a table and insert that recordset into a temp table. While the data is IN that temp table, I wish to change some values so I can then copy all the data back into the original master table.

I am trying to accomplish the table data transfer using an insert statement with a subselect as such:

Code:
Set RSInsertHeaderTmp = Server.CreateObject("ADODB.Recordset")
SQLInsertHeaderTmp = "INSERT INTO rccnhdwebtmp10 (SELECT * FROM rccnhd10 WHERE (contno = '   25432'))"
RSInsertHeaderTmp.Open SQLInsertHeaderTmp, Conn

I need to know the correct format for this statement so I may properly copy my data from one table to another. I wish to use this method because there are quite the number of columns and I don't want to insert column by column for the recordset.

Plus I want to use the temp table method because due to the nature of the program, if the data transfer is interrupted, I have a solid group of data to backtrack with.

Thank you all in advance!

Reply With Quote
  #2  
Old June 25th, 2002, 03:38 PM
MattR MattR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: High above the mucky-muck (Columbus, OH)
Posts: 266 MattR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
Send a message via ICQ to MattR
Make sure you do INSERT INTO table VALUES ( select ). This requires you to SELECT in the exact same order as the columns exist in the target table. The target table must also exist before you execute the query.

Try SELECT INTO, this will generate the temp table FROM the results of the subselect.

Otherwise you will have to specify the columns like:
INSERT INTO #temp ( column1, column2 ) VALUES ( SELECT col1, col2 FROM othertable )

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Insert w/Subselect format question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap