首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-10-13 
写一个存储过程,执行时候execute(1),写入一万个数据,编译有错误create procedure p@strSql intasbeginwhil

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

热点排行