日期:2014-05-17  浏览次数:20425 次

写一个存储过程,执行时候execute(1),写入一万个数据,编译有错误
create procedure p 
@strSql int 
as
begin
while @strSql<10000
begin
insert into t_practice 
values (@strSql,100)
end
@strSql=@strSql+1
end 


------解决方案--------------------
下面这样,变量赋值要用set 或者select 
并且要把赋值的也放到while 循环体里面
SQL code
create procedure p  
@strSql int  
as
begin
while @strSql<10000
begin
insert into t_practice values (@strSql,100)
SET @strSql=@strSql+1

end
end