Locate Column Name in all Tables

  • I have a deduping project coming up, which will inolved consolidating duplicate records in one table and changing foreign key values in other tables that reference the first table. The DB involved is on SQL 2000

    Is there a command, function or script that will identify all tables which contain a specific column name?

  • something like this should work;

    select object_name(id) from syscolumns where name = 'col1'

    David

    @SQLTentmaker

    “He is no fool who gives what he cannot keep to gain that which he cannot lose” - Jim Elliot

  • Alternatively you can do (I have this in a snippet)

    SELECT *

    FROM INFORMATION_SCHEMA.COLUMNS

    WHERE [COLUMN_NAME] = @ColumnName

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply