当前位置: 代码迷 >> Sql Server >> 写一个存储过程,执行时候execute(1),写入一万个数据,编译有异常
  详细解决方案

写一个存储过程,执行时候execute(1),写入一万个数据,编译有异常

热度:99   发布时间:2016-04-27 10:49:26.0
写一个存储过程,执行时候execute(1),写入一万个数据,编译有错误
create procedure p 
@strSql int 
as
begin
while @strSql<10000
begin
insert into t_practice 
values (@strSql,100)
end
@[email protected]+1
end 


------解决方案--------------------
下面这样,变量赋值要用set 或者select 
并且要把赋值的也放到while 循环体里面
SQL code
create procedure p  @strSql int  asbeginwhile @strSql<10000begininsert into t_practice values (@strSql,100)SET @[email protected]+1endend
  相关解决方案