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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing rows from within a stored procedure... ?

Status
Not open for further replies.

adek

Programmer
May 13, 2002
8
FI
Hi,

how can one access rows from a query from within the stored procedure?? The query is a dynamic one (because the DB-name is dynamic).
This does'nt apparently work:
declare @Var cursor for
execute sp_executesql @sql
open...

Like this (working version) for the static query:
declare @Var cursor for
select ID from dbo.Tbl
open ...

How can I make the upper version work?

Please help!!
//adek
 
Hi,

u will have to do it some thing like this

declare @sql varchar(200)

set @SQL = 'Declare var cursor for SELECT * from table'
exec(@sql)
open var


Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top