How to locate a table from different databases ?

  • We have a 3rd party applications running on SQL-Server. It has created a series of databases with views, tables, etc. I would like to use some sp to query all databases to return me to which database a particular table is located. Thanks.

  • select name from master..sysdatabases

    Get resultsdets in to a cusror and loop through this query...

    exec 'if object_id(''' + @db_name + '..' + @tablename + ''') is not null Print '''table exists''''

    Cheers,

    Prakash

    Prakash Heda
    Lead DBA Team - www.sqlfeatures.com
    Video sessions on Performance Tuning and SQL 2012 HA

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

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