Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Cursor for stored procedure results?

Status
Not open for further replies.

ubivis

Programmer
Apr 24, 2006
2
CA
I am trying to do the following:

DECLARE @command varchar (1024)
DECLARE login_curs CURSOR FOR
exec REMOTE_SERVER.someDB.dbo.generate_sql_statements
OPEN login_curs

FETCH NEXT FROM login_curs INTO @command
WHILE (@@fetch_status <> -1)
BEGIN
Exec sp_executesql @command
FETCH NEXT FROM login_curs INTO @command
END
CLOSE login_curs
DEALLOCATE login_curs

Is this possible somehow?
I am trying to have one stored procedure
generate many statements of of a linked
server. Those statements must then be executed
on the local server. The statements generated
may total more than 8000 characters so I cannot
use a vachar as a datatype and apperently you
cannot use a "text" data type as a return value.
Is this an impossible dream?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top