I want to find out all tables having a column let's say test. How to obtain this? I need DBName, TableName, testcolumnexist(Yes/No), TableCreateDate and ProductName details.
The tricky part is tablenames. I have tables with IDs appended at the end. Below is the entire scenario:
- bColumn to find = test
- Tables = Logs#, Details#, Data#
Where # represents IDs coming from different table master. i.e. select id from master where id< 5).
So my tables are like Log1, Details1, Data1 for ID = 1, Log2, Details2, Data2 for ID = 2 and so on
Output: DBName, TableName, testcolumnexist(Yes/No), TableCreateDate, ProductName
Note that ProductName column exist in master table.
Best Answer
This will give you the Schema and Table names along with YES or NO and Creation date:
How the
master
table works is unclear but it seems that adding such aWHERE
clause should work:This will mix the list of name with the list of ids from master. Names can be added to the list or it could be replaced by a Names table.
By the way,
master
is not a proper name for a table since it is also a system database name.This query adds
productname
from sample@master
table forid < 5
: