在 SQL 中,可以使用以下语句检查表是否存在:
IF EXISTS (SELECT 1 FROM sys.tables WHERE name = 'table_name')
BEGIN
PRINT 'Table exists'
END
ELSE
BEGIN
PRINT 'Table does not exist'
END
其中,table_name
应替换为要检查是否存在的表名。如果表存在,则会输出 Table exists
;如果表不存在,则会输出 Table does not exist
。