Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automatically generating a 'create table' command
Message
 
To
21/10/2004 11:32:54
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00953298
Message ID:
00953536
Views:
12
>You mentioned CREATE YABLE, what's wrong with that command? I understood from your message that you wanted another solution?
>
>>Thanks, but I was hoping to start building the tables programmatically rather than have one living. We distribute this application and I need to create this table on each work station.


having your actual tables in a dir try to use this code and add some functionality to do all the tables at the same time
USE yourTable

COPY STRUCTURE TO yourTableStructure extende 

SELECT 0 
USE yourTableStructure
LOCAL lcSQLCreateTbl
lcSQLCreateTbl = "create table " + ALLTRIM(yourTableStructure.Table_name) + " ("
SCAN
	lcSQLCreateTbl = lcSQLCreateTbl + ALLTRIM(yourTableStructure.field_name) + " " + yourTableStructure.Field_Type + ;
									  [(] + ALLTRIM(STR(yourTableStructure.Field_Len)) + ;
									  IIF(yourTableStructure.Field_Type = 'N', [,] + ALLTRIM(STR(yourTableStructure.Field_dec)),"") + [),]
ENDSCAN
lcSQLCreateTbl = LEFT(lcSQLCreateTbl,LEN(lcSQLCreateTbl) - 1) + ")"
? lcSQLCreateTbl
CLOSE ALL
.......
DO WHILE .T.
      ME.Work()
ENDDO
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform