using cursor in sql server :
cursor used to capture collection of result used after for looping or fetching in sub query .
example :
USE yourdbname
GO
declare cur cursor for
select user_id from USERS
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
GO
cursor used to capture collection of result used after for looping or fetching in sub query .
example :
USE yourdbname
GO
declare cur cursor for
select user_id from USERS
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
GO
------------------------------------------------------------
to get values from cursor should declare variable or scalar table keep cursor values.
No comments:
Post a Comment