×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

35 tables with the same structure in one

35 tables with the same structure in one

35 tables with the same structure in one

(OP)
Hello!


I have 35 tables named id_01, id_02, ... id_35 with the same structure. How can I make a single id_total table?

RE: 35 tables with the same structure in one

CODE

SELECT * FROM Id_01 WHERE .f. INTO CURSOR cTotal READWRITE
FOR lnFor = 1 TO 35
   INSERT INTO cTotal
   SELECT * FROM ([Id_]+PADL(lnFor,"0",2))
NEXT

SELECT cTotal
BROW NORMAL 


NOT TESTED!!!

Borislav Borissov
VFP9 SP2, SQL Server

RE: 35 tables with the same structure in one

(OP)
sorry I'm a beginner but at INSERT INTO cTotal give syntax error

RE: 35 tables with the same structure in one

I think Borislav missed out a semi-colon after the INSERT:

CODE -->

SELECT * FROM Id_01 WHERE .f. INTO CURSOR cTotal READWRITE
FOR lnFor = 1 TO 35
   INSERT INTO cTotal  ;
   SELECT * FROM ([Id_]+PADL(lnFor,"0",2))
NEXT

SELECT cTotal
BROW NORMAL 

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: 35 tables with the same structure in one

Also, be aware that Borislav's code will create a cursor. A cursor is a temporary table. It will contain the correct data, but it will be lost when you close it, or when you come out of VFP.

To create a permanent table, change INTO CURSOR (in the first line) to INTO TABLE. The table will be created in your default directory. If that's not what you want, include the full path with the table name.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: 35 tables with the same structure in one

(OP)
INSERT INTO cTotal;
SELECT * FROM ([Id]+PADL(lnFor,"0",2))

Function argument value, type or count is invalid

RE: 35 tables with the same structure in one

I think this is where that error lies:

PADL(lnFor,"0",2)

It should be:

PADL(lnFor, 2, "0")

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: 35 tables with the same structure in one

Gabydrdoom,

You received several replies to your question. It would be nice to know if these were helpful, and if the problem is now solved. If nothing else, this could be helpful for any other developer who has a similar problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close