Hi,
Do you need to open and iterate through the cursor dynamicaly?
What happens when you declare your cursor like below, and open and iterate outside of the dynamic sql statement?
DECLARE @SQL NVARCHAR(4000)
SET @SQL =
'DECLARE test_cursor CURSOR FOR
SELECT * FROM ' +@CurrentTable
EXEC sp_executesql @SQL
OPEN test_cursor
FETCH NEXT FROM test_cursor INTO @CurrentRow
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Your dynamically created Cursor works mate!'
FETCH NEXT FROM test_cursor INTO @CurrentRow
END
CLOSE test_cursor
DEALLOCATE test_cursor'
Hope it helps, and let me know how you get on?