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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

35 tables with the same structure in one

Status
Not open for further replies.

gabydrdoom

Programmer
Jul 1, 2020
12
0
1
RO
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?
 
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
 
sorry I'm a beginner but at INSERT INTO cTotal give syntax error
 
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 [highlight #FCE94F][b] ;[/b][/highlight]
   SELECT * FROM ([Id_]+PADL(lnFor,"0",2))
NEXT

SELECT cTotal
BROW NORMAL

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
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 [tt]INTO CURSOR[/tt] (in the first line) to [tt]INTO TABLE[/tt]. 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
 
INSERT INTO cTotal;
SELECT * FROM ([Id]+PADL(lnFor,"0",2))

Function argument value, type or count is invalid
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top