Help need to identify if a table exists

  • I want to check if a table exists in a database. I tried to use

    SELECT name FROM sysobjects WHERE xtype = ā€˜Uā€™; but this gives listing for the current database. I want a query that will go to any specified database and check the table existence.

  • Try following query:

    sp_MSforeachdb " select '?' as dbname,name from ?.dbo.sysobjects where xtype='U' and name='Table_name' "

    Thanks,

    SR

     

    Thanks,
    SR

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

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