Check if table exists in SQL Server

前端 未结 28 1558
梦如初夏
梦如初夏 2020-11-22 04:23

I would like this to be the ultimate discussion on how to check if a table exists in SQL Server 2000/2005 using SQL Statements.

When you Google for the answer, you g

28条回答
  •  一生所求
    2020-11-22 04:54

    There is one more option to check if the table exists across databases

    IF EXISTS(SELECT 1 FROM [change-to-your-database].SYS.TABLES WHERE NAME = 'change-to-your-table-name')
    BEGIN
        -- do whatever you want
    END
    

提交回复
热议问题