Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find tables that have a column with a certain name?
Message
 
 
To
22/11/2010 22:36:33
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01463436
Message ID:
01490251
Views:
50
>>>I have a directly full of dbf tables (not attached to a dbc). Is there a way I can programmatically determine which tables have a column named "ifkey"?
>>>
>>>If not possible on a directory of free tables, would it be possible if they were attached to a DBC? How would you query this matter if they were atatched to a dbc?
>>
>>If all the tables are in a DBC........
>>SELECT cur1.objectname AS tablename ;
>>  FROM myDbc.dbc cur1;
>>     JOIN myDbc.dbc cur2 ON cur1.objectid = cur2.parentid;
>> WHERE cur2.objecttype = "Field" AND cur2.objectname = myFieldName
>>
>>If they're not in a DBC then try Naomi's loop
>
>A little more help from you?
>
>What would be the que query for "all tables that *do not* contain a field named [id]"?
>
>All tables are in a dbc.
select * from MyDBC cur1 where ObjectType = 'Table' ;
 and not exists (select 1 from myDBC cur2 where cur2.ObjectID = cur1.ParentID ;
and cur2.ObjectType = 'Field' and cur2.ObjectName = 'ID')
from the top of my head - you need to test.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform