在一张表上,我想新增加一个序号列(例如:000001,000002.。),设列名为aa,表名为A,然后插入另一个新建的表AA,语句如下:
select *,right('000000'+convert(varchar(6),select count(1) from A),6) as ll into AA
from A
但总提示我错误,请问应该如何修改一下?
select *,right('000000'+convert(varchar(6),select count(1) from A),6) as ll into AA
from A
但总提示我错误,请问应该如何修改一下?
select *,right('000000'+convert(varchar(6),select count(1) from A),6) as ll into AA
from A
但总提示我错误,请问应该如何修改一下?select * , ll = identity(int,1,1) into tmp from a
select col1,col2 , right('000000'+cast(ll as varchar) ,6) ll into aa from tmp
drop table tmp
from A
from A b
select 然后再试 select into
create table a (id int)
go
insert into a
select 5 union all
select 444 union all
select 55 union all
select 75 union all
select 4385godeclare @i int
set @i=0select *,'000000' as ll into aa from a
update aa set ll=right(ll+cast(@i as varchar(10)),6),@i=@i+1select * from aa
godrop table aa,a
go
id ll
----------- ------
5 000001
444 000002
55 000003
75 000004
4385 000005(所影响的行数为 5 行)