Want to check if two specific columns exist in more than one table

Database
Enthusiast

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.

6 REPLIES
Teradata Employee

Re: Want to check if two specific columns exist in more than one table

Ideally you should have this information from some kind of model.

But you can find that information using DBC.COLUMNS view.

HTH!

Enthusiast

Re: Want to check if two specific columns exist in more than one table

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

--Sri

Enthusiast

Re: Want to check if two specific columns exist in more than one table

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.

Senior Apprentice

Re: Want to check if two specific columns exist in more than one table

select DatabaseName, TableName
from dbc.ColumnsV
where ColumName in ('party_no', 'appl_id', 'co_no')
group by 1,2
having count(*) = 3
Enthusiast

Re: Want to check if two specific columns exist in more than one table

yep..its good..

Thank you .

--Sri

Enthusiast

Re: Want to check if two specific columns exist in more than one table

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