视图是 虚拟表,没有自增这个概念语法在视图里。可以用 ROW_NUMBER() OVER(ORDER BY COLUMN_NAME ) as RN 来生成序号。别的没办法。
create table tb ( name varchar(32),address nvarchar(32)) go insert into tb select 'sdf','aasdfas' union all select 'asdf','234r23'select ROW_NUMBER() over(order by name )as rn,* from tb /* rn name address 1 asdf 234r23 2 sdf aasdfas */
go
insert into tb select 'sdf','aasdfas' union all
select 'asdf','234r23'select ROW_NUMBER() over(order by name )as rn,* from tb
/*
rn name address
1 asdf 234r23
2 sdf aasdfas
*/