ALTER TABLE 你的表名 ADD 列名 int IDENTITY(1, 1) PRIMARY KEY
ALTER TABLE tb_name ADD ID INT IDENTITY(1,1) GO
alter table tablename add ID int identity(1,1)
if object_id('tb') is not null drop table tb go create table tb(name varchar(50)) insert into tb select 'a' insert into tb select 'b' go alter table tb add id int identity(1,1) go select * from tb
ADD 列名 int IDENTITY(1, 1)
PRIMARY KEY
ADD ID INT IDENTITY(1,1)
GO
add ID int identity(1,1)
drop table tb
go
create table tb(name varchar(50))
insert into tb select 'a'
insert into tb select 'b'
go
alter table tb add id int identity(1,1)
go
select * from tb
晕死 没那么简单 我的是SQL08 操作链表是:数据库-表-右键-设计 进去后可以添加新列 可是那列值是空值,无法添加自增的功能!因为此列全为空值 所以不能设置为主键!
我想加入一列主键列,然后取消原来的主键 , 此列的内容从1开始自增1, 不用代码的形式 难道就办不到吗?
“kkk”表
- 无法修改表。
不能将值 NULL 插入列 'idid',表 'vv.dbo.Tmp_kkk';列不允许有 Null 值。INSERT 失败。
语句已终止。
ADD ID int IDENTITY(1, 1)
PRIMARY KEY
我曾经设置过SQL05的 是这种设置 但是貌似SQL08不是这么设置...
ADD 列名ID int IDENTITY(1, 1)
PRIMARY KEY
ADD 列名ID int IDENTITY(1, 1)
PRIMARY KEY
http://msdn.microsoft.com/zh-cn/vs2008/x5s13zy2.aspx