日期:2014-05-18 浏览次数:20531 次
if object_id('a','u')>o alter table a drop column ... else exec('create table a(...)')
------解决方案--------------------
IF OBJECT_ID('a') IS NOT NULL
修改
else
创建
------解决方案--------------------
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[TB]') AND type in (N'U')) --U 代表你查询的是表 DROP TABLE [TB] GO
------解决方案--------------------
IF EXISTS ( SELECT 1 FROM SYSOBJECTS WHERE ID=OBJECT_ID(N'TABLENAME') AND OBJECTPROPERTY(ID,N'ISTABLE')=1 ) ALTER TABLE …… GO ELSE CREATE TABLE …… GO