I want to use dynamic sql to select the database name for a cursor. Is this or something similar possible using sybase ASE?
create procedure myproc
@dbname = varchar(20) = null as
declare mycur cursor for select @dbname..mytable
... use cursor
go
You can create dynamically a temp table
something like
create procedure myproc (@dbname ....)
as
exec ('SELECT ...... into tempdb..test FROM '+@dbName+'..mytable')
-- and then
DECLARE Cursor1 for tempdb..test
open cursor
etc