DECLARE @sql VARCHAR (MAX)
DECLARE @mid AS BIGINT
DECLARE @cursor AS CURSOR
SET @SQL =
SELECT [MERCHANT_ID] from [Reports].[MONAD\karal.ramil].[REF#19414MHTNEEDED]
OPEN @cursor
FETCH @cursor INTO @mid
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @mid
SELECT MERCHANT_NUMBER
INTO #TEMP
FROM [BI].[dbo].[MERCHANT_PROFILE]
WHERE YEAR_MONTH =201503 AND THIS_MHT_TYPE ='MRCH' AND MERCHANT_NUMBER LIKE '%' + @mid
FETCH NEXT
FROM @cursor INTO @mid
END
CLOSE @cursor
DEALLOCATE @cursor
--error-------
Msg 16950, Level 16, State 2, Line 35
The variable '@cursor' does not currently have a cursor allocated to it.
Msg 16950, Level 16, State 2, Line 40
The variable '@cursor' does not currently have a cursor allocated to it.
Msg 16950, Level 16, State 2, Line 52
The variable '@cursor' does not currently have a cursor allocated to it.
Msg 16950, Level 16, State 2, Line 53
The variable '@cursor' does not currently have a cursor allocated to it.