写一个存储过程,执行时候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 循环体里面
create procedure p @strSql int asbeginwhile @strSql<10000begininsert into t_practice values (@strSql,100)SET @strSql=@strSql+1endend