/*
将游标定以在字串里,例如:
*/declare @name sysname-- 将游标 Cursor_Test 定义在字串里:
exec sp_executesql N'declare Cursor_Test cursor for select top 10 name from sysobjects'open Cursor_Test
fetch next from Cursor_Test into @namewhile @@fetch_status = 0
begin
print @name
fetch next from Cursor_Test into @name
endclose Cursor_Test
deallocate Cursor_Test