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)
 cursor Issue

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-11-12 : 09:29:33
sudesh writes "Consider the following scenario,

CREATE testProc (@param varchar(100))
AS

declare @curTable cursor
declare @sqlstr varchar(400)

--(1)
set @sqlstr = 'SELECT * FROM TEST_TABLE WHERE TESTFIELD IN (@param)'

--(2)
set @curTable = cursor for
@sqlstr

open @curTable
.....
/* do some operation*/
......
close @curTable
deallocate @curTable
GO

In the above sample code i am taking param as the input parameter. Within the Stored Procedure, ie in the (1) step i will build a query using this parameter.
And in the (2) step i am trying to create a cursor object using a query which is nothing but value of @sqlstr variable.

But when i execute this...i am getting an error like "Incorrect Syntax Near @sqlstr" ...please help me..

thanking u in advance,
Sudesh shetty"
   

- Advertisement -