Solved

SQL action statement question

Posted on 1998-05-14
5
205 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

713 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