Подтвердить что ты не робот

Пример запроса SQL Server 2008 при создании курсора для записи записей

Есть ли у кого-нибудь опыт в создании курсора для циклического переноса множества записей? Если вы это сделаете, вы можете предоставить мне базовый пример. Благодаря

4b9b3361

Ответ 1

declare cur cursor for 
select id from tbl 
open cur
declare @id int
fetch next from cur into @id
while (@@FETCH_STATUS = 0)
begin
    print(@id)
    fetch next from cur into @id
end
close cur
deallocate cur

-- just replace "tbl" with your table name and "id" with your field name
-- and do whatever you want in begin-end block (now it simply prints the id of each record)