SQL Server游標(biāo)與循環(huán)例子
發(fā)布日期:2023/2/2 21:49:21 瀏覽量:
SQL Server游標(biāo)與循環(huán)例子
----------------------------------------------------------------------------------------------
declare @ID varchar(20); --ID
declare @filepath varchar(200);--路徑
declare @cursorTmpHelp cursor;--游標(biāo)
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
馬上咨詢: 如果您有業(yè)務(wù)方面的問題或者需求,歡迎您咨詢!我們帶來的不僅僅是技術(shù),還有行業(yè)經(jīng)驗積累。
QQ: 39764417/308460098 Phone: 13 9800 1 9844 / 135 6887 9550 聯(lián)系人:石先生/雷先生