一 使用OBJECT_ID方式

IF OBJECT_ID('dbo.TableName') IS NOT NULL
BEGIN
    DROP TABLE dbo.TableName
    PRINT '<<< DROPPED TABLE dbo.TableName>>>'
END

 

二 查询sysobjects表

IF EXISTS (SELECT * FROM sysobjects WHERE name = "TableName" AND type = "U")
BEGIN
    DROP table TableName
    PRINT "TABLE %1! DROPPED", TableName
END

posted on 2013-03-30 14:44  烤德  阅读(729)  评论(0编辑  收藏  举报