how to check specified table exists in the database or not

  • Hi,

    how to check specified table exists in the database or not,

    means

    Database name is master

    table name is table1

    how to check if table1 exists or not in the master(database)

    plz help in this regard.....

  • IF EXISTS (SELECT 1 from master.dbo.sysobjects where name = 'Table1' and xtype = 'U')

    BEGIN

    -- do something here.

    END

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Concur...

    if you don't want to do something ,then simply

    select name from master.dbo.sysobjects where name ='Table1' and xtype ='U'

    karthik

  • GilaMonster (5/13/2008)


    IF EXISTS (SELECT 1 from master.dbo.sysobjects where name = 'Table1' and xtype = 'U')

    BEGIN

    -- do something here.

    END

    Hi Gila,

    I don't understand, Are you spend all of your day in sql servercentral?, why i am asking this question is before i answer the post always i am finding your post prior

    tell me any special techniq ..........

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

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