May 7, 2003 at 2:58 pm
Does anyone have a script that would accept a column name and a value for that column as parameters and return all table names that have the column and the value? This would be a great help to me because I maintain a database with over 1,000 tables.
"I hope you enjoy your retirement as much as I will."
When the snows fall and the white winds blow,The lone wolf dies but the pack survives.
Once you've accepted your flaws, no one can use them against you.
May 7, 2003 at 3:21 pm
select * from sysobjects a, syscolumns b
where a.id = b.id
and b.name = 'YourColumnName'
Darren
Darren
May 8, 2003 at 10:19 am
Thanks Darren. That query will list all of the tables that contain the column. The final step is to query the listed tables and limit the result to those tables that contain the value I am looking for. Do you have a script that will do that?
"I hope you enjoy your retirement as much as I will."
When the snows fall and the white winds blow,The lone wolf dies but the pack survives.
Once you've accepted your flaws, no one can use them against you.
May 11, 2003 at 6:39 pm
Wrap the above query in a cursor, then for each table name from sysobjects you can dynamically build a select query then call EXECUTE passing in the sql statement with the appended table name and "where" clause.
Darren
Darren
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply