Solved

SQL action statement question

Posted on 1998-05-14
5
191 Views
Last Modified: 2010-08-05
I am trying to bring data from one table into another, and the INSERT INTO with a nested SELECT statement works fine, with one exception.  Some of the fields from the source table, although their names don't match, are needed to be brought across into the correct field.  For example, both tables might have FROM and TO fields, so they map across easily, but one table has FROM_____V and TO_______V which map to FROM_Special and TO_Special respectively.  Is there any way that I can map the fields using the INSERT INTO with SELECT statement I described above?  If there isn't a way using that statement, how about in another way?  Any help would be greatly appreciated. =)
0
Comment
Question by:S_Charette
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
faster earned 100 total points
ID: 1177519
You can first execute the select statement on the source, then save the fields in memory variable so that you can then issue an insert to the target, of course, this way you need a loop.
0
 

Author Comment

by:S_Charette
ID: 1177520
Any way to do it without the loop?
0
 
LVL 7

Expert Comment

by:faster
ID: 1177521
A loop is quit simple and I don't think that it will be inefficient.
0
 

Author Comment

by:S_Charette
ID: 1177522
Well, on a 28MB file, a loop is unefficient enough to make a difference.  Looks like I don't have much of a choice, tho :)  Thanks
0
 

Author Comment

by:S_Charette
ID: 1177523
Actually, I just figured it out... in the SELECT statement I need to use table.field AS [new field name] =)
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now