For your infromation:-) 是stored procedurecreate table tt (n nvarchar(10)) insert into tt select 'a' union all select 'b' union all select 'c' union all select 'd' go select * from tt go create proc d @id int as declare @bh int set @bh=@id exec('select identity(int,'+@bh+',1) id,* into #t from tt select * from #t drop table #t') go exec d 10 go drop proc d drop table tt
是stored procedurecreate table tt (n nvarchar(10))
insert into tt select 'a' union all select 'b' union all select 'c' union all select 'd'
go
select * from tt
go
create proc d
@id int
as
declare @bh int
set @bh=@id
exec('select identity(int,'+@bh+',1) id,* into #t from tt select * from #t drop table #t')
go
exec d 10
go
drop proc d
drop table tt