try: alter column id=identity(int,1,1) id最后再取个别的名子,如 idnum
那我修改 alter table tablename alter column id int default 自定义函数 go 也说有错
ID里原來有值嗎? 如果有值,就可能出錯,因為identity是自動累計的值
alter table tablename alter column id int identity(1,1) not null go
把原来的字段删除, 再增加 column id int identity(1,1) not null
alter table tablename add default 1 for id
--把default后面改成自定义函数就可以了 --测试:create table b( seq_no int identity(1,1), b varchar(10), c datetime ) go alter table b add default getdate() for c with values go insert into b(b) values('a') insert into b(b) values('b') insert into b(b) values('d') insert into b(b) values('c') select * from bdrop table b
alter column id=identity(int,1,1)
id最后再取个别的名子,如 idnum
alter table tablename
alter column id int default 自定义函数
go
也说有错
如果有值,就可能出錯,因為identity是自動累計的值
alter column id int identity(1,1) not null
go
再增加
column id int identity(1,1) not null
--测试:create table b(
seq_no int identity(1,1),
b varchar(10),
c datetime
)
go
alter table b add default getdate() for c with values
go
insert into b(b) values('a')
insert into b(b) values('b')
insert into b(b) values('d')
insert into b(b) values('c')
select * from bdrop table b