1DECLARE @id INT
2DECLARE @name NVARCHAR(100)
3DECLARE @getid CURSOR
4
5SET @getid = CURSOR FOR
6SELECT table.id,
7 table.name
8FROM table
9
10OPEN @getid
11FETCH NEXT
12FROM @getid INTO @id, @name
13WHILE @@FETCH_STATUS = 0
14BEGIN
15 EXEC stored_proc @varName=@id, @otherVarName='test', @varForName=@name
16 FETCH NEXT
17 FROM @getid INTO @id, @name
18END
19
20CLOSE @getid
21DEALLOCATE @getid
22