I have the following cursor in my Stored Procedure
 
-----------------------------------------------------
DECLARE crsPoll CURSOR
FOR SELECT TOP  1
   column1, column2
FROM   table
-----------------------------------------------------
 
I need the TOP 1 integer to be a variable, i.e. TOP @intTop
 
But this won't work, it says "Incorrect Syntax"
 
I also tried to set the whole select statement as variable and then execute it like so;
 
-----------------------------------------------------
DECLARE crsPoll CURSOR
FOR EXECUTE sp_executesql @sql
-----------------------------------------------------
 
Where the variable @sql is
 
-----------------------------------------------------
DECLARE @sql NVARCHAR(1024)
SET @sql = 'SELECT TOP  ' + CAST(@intTop AS VARCHAR(3)) + '
   column1, column2
FROM   table'
-----------------------------------------------------
 
But still no luck..
Any ideas?
---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/

Reply via email to