Check if table exists in SQL Server

前端 未结 28 2011
梦如初夏
梦如初夏 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

    If this is to be the 'ultimate' discussion, then it should be noted that Larry Leonard's script can query a remote server as well if the servers are linked.

    if exists (select * from REMOTE_SERVER.MyOtherDatabase.sys.tables where name = 'MyTable')
        print 'Exists'
    

提交回复
热议问题