Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comparing dbf structures
Message
From
26/03/2002 12:01:02
 
 
To
26/03/2002 11:44:19
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00637329
Message ID:
00637341
Views:
17
Hi!

You can use COPY STRUCTURE EXTENDED comand to copy structure of both tables into new information tables holding records for each field. Then using these tables in a single query you can determine differences:
SELECT T1.*, "Does not match" as Difference_Type ;
  From TableOneStructure T1 ;
  inner TableTwoStructure T2 ;
    on T1.FIELD_NAME==t2.FIELD_NAME ;
  where NOT (T1.FIELD_TYPE==T2.FIELD_TYPE AND T1.FIELD_LEN = T2.FIELD_LEN AND ...) ;
UNION ALL ;
SELECT T1.*, "In table1 and not in table2" as Difference_Type From TableOneStructure T1 ;
  where T1.FIELD_NAME NOT IN (Select FIELD_NAME from TableTwoStructure) ;
UNION ALL ;
SELECT T2.*, "In table2 and not in table1" as Difference_Type From TableTwoStructure T2 ;
  where T2.FIELD_NAME NOT IN (Select FIELD_NAME from TableOneStructure) ;
The structure of table created by COPY STRUCTURE EXTENDED command see in teh MSDN help for this command.

Did not tested a query, but the idea is like that...

HTH.

>Hello all,
>
>Is there a command to compare the structures of 2 different
>.dbf tables? or do I have to do AFIELDS() for each table
>then ASCAN the data?
>
>Thanks.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform