Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Opening a cursor with a dynamic SQL Line

Author  Topic 

Ben
Starting Member

2 Posts

Posted - 2001-03-22 : 13:05:51
Wondering if anyone can help me please.
I open a cursor as follows:
DECLARE @Accept_Crsr CURSOR
SET @Accept_Crsr = CURSOR LOCAL SCROLL FOR
select fDataExtractValue, fAcceptStructsID from tLookAcceptStructs where fAcceptStructsID IN (3,4) etc....
but the problem is with the "IN" clause, because the numbers shown are passed in to the stored proc as a parameter I need to make the line dynamic. My first thought was to build a string for the SQL line, and then execute it, along the lines of:
SET @Accept_Crsr = CURSOR LOCAL SCROLL FOR EXECUTE (@mySQLstring)
but this doesn't work. Any suggestions??
Thanks
   

- Advertisement -