哪错了?
alter table D_SchEduleMain alter column SchEduleMainStatus int default 1
服务器: 消息 156,级别 15,状态 1,行 2
在关键字 'default ' 附近有语法错误。
CREATE TABLE [D_SchEduleMain] (
[SEMID] [int] IDENTITY (1, 1) NOT NULL ,
[UID] [int] NULL ,
[SchEduleMainTitle] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
[SchEduleMainMemo] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
[SchEduleMainFirstTime] [datetime] NULL ,
[SchEduleMainLastTime] [datetime] NULL ,
[SchEduleMainImportant] [int] NULL ,
[SchEduleMainType] [int] NULL ,
[SchEduleMainStatus] [int] NULL CONSTRAINT [DF__D_SchEdul__SchEd__239E4DCF] DEFAULT (0),
PRIMARY KEY CLUSTERED
(
[SEMID]
) ON [PRIMARY] ,
FOREIGN KEY
(
[SchEduleMainImportant]
) REFERENCES [D_SchEduleImportant] (
[SEIID]
),
FOREIGN KEY
(
[SchEduleMainType]
) REFERENCES [D_SchEduleSort] (
[SEID]
),
FOREIGN KEY
(
[UID]
) REFERENCES [D_admin] (
[adminID]
)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
[解决办法]
alter table D_SchEduleMain
add constraint AddDefault default(1) for SchEduleMainStatus with values
[解决办法]
不能直接修改表的默认值,必须先删除默认值约束,然后添加默认值约束。