Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Web Buyers Guide
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:
Speeding Shipping, Improving Compliance – Read the ScanCode Systems Case Study
  #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: 7
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


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway