SQL中查找到的:
--(1)
SELECT IDENTITY(int, 1,1) AS ID_Num
INTO NewTable
FROM OldTable
--(2)
SELECT ID_Num = IDENTITY(int, 1, 1)
INTO NewTable
FROM OldTable
但是如果是直接修改表的属性或者是ALERT TABLE增加一个字段又如何实现?
ALTER TABLE OldTable //表名
ADD ID_Num IDENTITY(int, 1, 1) //字段名
创建TABLE时用到
CREATE TABLE new_employees
(
id_num int IDENTITY(1,1),
fname varchar (20),
minit char(1),
lname varchar(30)
)