var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Multiple Table Query.
Hi all, I am new here. Need some help. I have a database that has 370 tables that match %_REF_% naming. All of these tables have a column call ds_name.
I need to get a list of all values of ds_name for each table. Can anyone help please.
This gives me the list of table name:
select name from sys.tables
where name like '%_ref_%'
But then want to select the ds_name value for each of these tables
Holy Cow...what a bad design (This is a rude comment and I apologize)
You need to let this run, the take the generated code, and execute that
SELECT 'SELECT DISTINCT ds_name FROM ' + TABLE_NAME + ' UNION '
WHERE TABLE_NAME LIKE '%_REF_%'
Just remove the last UNION and Run that
Do you need to know that count of each value, or the source of where the value comes from?
Thanks for the reply Brett.
Preferably results would be Table Name: ds_name
Or at least have the results grouped by Table
Last edited by mrmmartian; 06-07-12 at
Tags for this Thread