SQL Server游标与循环例子
发布日期:2023/2/2 21:49:21 浏览量:
SQL Server游标与循环例子
----------------------------------------------------------------------------------------------
declare @ID varchar(20); --ID
declare @filepath varchar(200);--路径
declare @cursorTmpHelp cursor;--游标
set @cursorTmpHelp=cursor for
select id,filepath from b_project_file WHERE filepath like ’%10.1.1.3%’;
open @cursorTmpHelp
fetch next from @cursorTmpHelp into @ID,@filepath;
WHILE @@FETCH_STATUS=0
begin
select @filepath = filepath from b_project_file where id=@ID
set @filepath=replace(@filepath,’10.1.1.3’,’10.1.1.10’)
update b_project_file set
filepath=@filepath
where id = @ID
fetch next from @cursorTmpHelp into @ID,@filepath;
end
close @cursorTmpHelp
deallocate @cursorTmpHelp
-----------------------------------------------------------------------------------------
declare @i int
set @i=1
while @i<30
begin
insert into test (userid) values(@i)
set @i=@i+1
end
马上咨询: 如果您有业务方面的问题或者需求,欢迎您咨询!我们带来的不仅仅是技术,还有行业经验积累。
QQ: 39764417/308460098 Phone: 13 9800 1 9844 / 135 6887 9550 联系人:石先生/雷先生