?
Solved

Insert a Table into another Table

Posted on 2003-03-31
6
Medium Priority
?
157 Views
Last Modified: 2010-04-06
I Use ADOQuery, Provider=Microsoft.Jet.OLEDB.4.0

I want to insert a Table in another Table
I Tried:
   Query1.Close;
   Query1.SQL.Clear;
   Query1.sql.add('INSERT INTO Table1');
   Query1.sql.add('SELECT * from Table2');
   Query1.ExecSQL;
   Query1.SQL.Clear;
   Query1.sql.add('select * from Table1');
   Query1.Open;

But the compiler says Table2 is unknow, I'm sure Table2 exist and it had the same Fields as Table1
0
Comment
Question by:misterstefano
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8237986
>the compiler says Table2 is unknow
the compiler?
usual if table 2 is missed you got an error only at runtime,
not at compiletime

maybe your problem is on another place?

meikl ;-)

btw. what database?
0
 

Author Comment

by:misterstefano
ID: 8238024
I Use 2 access-databases

>the compiler says Table2 is unknow ---> When I want to RUN (F9) the program

I think the problem is here:
Query1 is linked (Provider=Microsoft.Jet.OLEDB.4.0) on Table1, I think thats the reason why Table2 is unknow
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8238045
hi,

you cannot use delphi-object names
in sql-statements, use the physical tablenames instead

just guessing

meikl ;-)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
nafeelm earned 60 total points
ID: 8238617
try this ;

  Query1.Close;
  Query1.SQL.Clear;
  Query1.sql.add('INSERT INTO database1..Table1');
  Query1.sql.add('SELECT * from database2..Table2');
  Query1.ExecSQL;

  Query1.SQL.Clear;
  Query1.sql.add('select * from database1..Table1');
  Query1.Open;
0
 

Author Comment

by:misterstefano
ID: 8241748
nope, doesn't work.
The problem is that Query1 has connection with Table1 and not with Table2
0
 

Author Comment

by:misterstefano
ID: 8241819
I found it, The code works:

 Query1.Close;
 Query1.SQL.Clear;
 Query1.sql.add('INSERT INTO database1.mdb..Table1');
 Query1.sql.add('SELECT * from database2.mdb..Table2');
 Query1.ExecSQL;

 Query1.SQL.Clear;
 Query1.sql.add('select * from database1.mdb..Table1');
 Query1.Open;
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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