Declare @id int set @id=1 while @id<=1000 begin Insert Into table Select @id,'a','b' set @id=@id+1 end
若id字段为标识列:insert 表(name,type) select top 1000 'a','b' from master.dbo.syscolumns a,master.dbo.syscolumns b
若你的表中id不是自增的: select top 1000 identity(int,1,1) id into #t from sysobjects a,sysobjects b insert into table1(id,name,type) select id,'a','b' from #t drop table #t若你的表中id是自增的: insert into table1(name,type) select top 1000 'a','b' from sysobjects a,sysobjects b
select top 1000 identity(int,1,1) id into #t from sysobjects a,sysobjects b insert into table1(id,name,type) select id,'a','b' from #t drop table #t
若id非标识列:set nocount on declare @int set @i=0 while @i<1000 begin insert 表(id,name,type) select @i=@i+1,'a','b' end set nocount off
首先保証一個表超過1000條記錄,用下面語句我覺得最好insert 表(name,type) select top 1000 'a','b' from syscolumns
set @id=1
while @id<=1000
begin
Insert Into table
Select @id,'a','b' set @id=@id+1
end
select top 1000 'a','b' from master.dbo.syscolumns a,master.dbo.syscolumns b
select top 1000 identity(int,1,1) id into #t from sysobjects a,sysobjects b
insert into table1(id,name,type)
select id,'a','b' from #t
drop table #t若你的表中id是自增的:
insert into table1(name,type)
select top 1000 'a','b' from sysobjects a,sysobjects b
insert into table1(id,name,type)
select id,'a','b' from #t
drop table #t
若id非标识列:set nocount on
declare @int
set @i=0
while @i<1000
begin
insert 表(id,name,type)
select @i=@i+1,'a','b'
end
set nocount off
select top 1000 'a','b' from syscolumns