SQL 问题(急急急急急急急!)
请问在查询分析器中:表名:userinfo_list user_id:test1-999
user_uint:TO 怎么一次插进test1-999所有的用户
[解决办法]
declare @i int --变义变量@i set @i = 1 --初始化@i为1 while @i < 100 begin ------------------ insert into userinfo_list ([user_id],[user_name],user_unit) values( 'test ' + cast(@i as varchar(3)), 'test ' + cast(@i as varchar(3)), 'T0 ') set @i = @i + 1 end --------------------
[解决办法]
或者这样:
select top 999 identity(int,1,1) as id
into #
from master..sysobjects x, master..sysobjects y
insert into userinfo_list(user_Id, user_unit)
select 'test ' + convert(varchar(3), id), 'To '
from #
drop table #
[解决办法]
declare @i int --变义变量@i
set @i = 1 --初始化@i为1
while @i < 1000
begin ------------------
insert into userinfo_list ([user_id],user_unit) values( 'test ' + cast(@i as varchar(3)), 'T0 ')
set @i = @i + 1
end --------------------