-- 判斷數據庫表是否存在 select count(*) from sysobjects where id=OBJECT_ID('tableName'); -- 返回 1存在,0不存在 -- 判斷表字段是否存在 select count(*) from syscolumns where id=OBJECT_ID('tableName') and name='colName'; -- 返回1 存在,0不存在 -- 判斷字段索引是否存在 select count(*) from sys.indexes where name='indexName'; -- 返回1存在,0不存在