All Forums Database
ankitislucky 10 posts Joined 04/09
17 Feb 2014
Want to check if two specific columns exist in more than one table

I want to find party_no column for table1 which doesn't have it. Table1 has appl_id & co_no in it. I want to find a table which has party_no, appl_id & co_no all in a single table so that I can join table1 with that specific table to get the party_no for those records from table1.

Adeel Chaudhry 773 posts Joined 04/08
17 Feb 2014

Ideally you should have this information from some kind of model.
 
But you can find that information using DBC.COLUMNS view.
 
HTH!

-- If you are stuck at something .... consider it an opportunity to think anew.

sgarlapa 88 posts Joined 03/13
17 Feb 2014

Hi Adeel, It is interesting. Can you give any sample query on DBC.columns for above requirment pls.
 
--Sri

Raja_KT 1246 posts Joined 07/09
17 Feb 2014

Hi Sri,
How about  say:
select databasename,tablename,columnname from dbc.columns where databasename in('dbc','retail'.....)
and columnname in('your column here'....)
If I understand it correctly.
 
 

Raja K Thaw
My wiki: http://en.wikipedia.org/wiki/User:Kt_raj1
Street Children suffer not by their fault. We can help them if we want.

dnoeth 4628 posts Joined 11/04
17 Feb 2014
select DatabaseName, TableName
from dbc.ColumnsV
where ColumName in ('party_no', 'appl_id', 'co_no')
group by 1,2
having count(*) = 3

 

Dieter

sgarlapa 88 posts Joined 03/13
18 Feb 2014

yep..its good..
Thank you .
--Sri

ankitislucky 10 posts Joined 04/09
18 Feb 2014

Thanks Dieter! I was thinking on same lines, its just I was selecting all three columns.

You must sign in to leave a comment.