Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create new table from another table values

Status
Not open for further replies.

LBC2

MIS
Aug 28, 2012
13
0
0
US
Hi,
How can I select all or part of the data from a table, create a new table and insert all the selected data in it.

My query would look like Select * from table but how can I create a new table and insert those data in it.
Thanks for your help
 
What version of Pervasive are you using? What is your goal for this process? Rather than create a new table, you might want to consider a VIEW.
To answer the question, you can use the SELECT INTO syntax. For example:
Code:
SELECT t1.f1, t1.f2 INTO #mytmptbl FROM t1 WHERE f1 < 100
The statement above will create a temporary table called #mytmptbl and insert records that match the restriction (f1 < 100).

The same statement can be made into a VIEW and reused easier:
Code:
CREATE VIEW v1 as SELECT t1.f1, t1.f2 FROM t1 WHERE f1 < 100
and then used with:
Code:
SELECT * FROM v1



Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
I am using Pervasive 11.

Since I am having problems converting with Access, the purpose is to create a new table with only part of the table. I can then use this new table, or give it to my helper to create some crystal report when I am too busy.

I just do not want them to connect directly to the master database.
 
Rather than create a new table, why not figure out why the queries aren't running properly. Creating a new table will only add to the complexity.

The syntax I posted will work in v11 however it will only create a new PSQL table. It won't create an Access table.


Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
I will check the queries in Crystal report, but It would be nice if the query worked the same against Pervasive and Access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top