Link to home
Create AccountLog in
Avatar of jralsen
jralsen

asked on

Using @@rowcount with delare cursor not working sqlserver

The @ @ rowcount not work using it after a declared cursor. Returns 0 but it should return 1

DECLARE @error int
DECLARE @rowcount int

DECLARE Pnr_Actualizables CURSOR FOR
SELECT TOP 150000 RES.resv_id 
FROM dbo.HOMOLOGACION_PNR HOM, dbo.RESV RES
WHERE HOM.rvas_cdg_pnr = RES.rvas_cdg_pnr
AND HOM.rvas_fch_reserva = RES.rvas_fch_reserva


SELECT @error = @@error,@rowcount = @@rowcount
PRINT 'Error 1: '+ convert(varchar,@error)
PRINT 'Registros 2: '+convert(varchar,@rowcount)

Open in new window

Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

The declaration of a cursor does not retrieve any data. You must also use the open cursor call. Also, as cursors are single row retrieves (using FETCH) you should only ever have one row returned.
ASKER CERTIFIED SOLUTION
Avatar of jralsen
jralsen

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of jralsen
jralsen

ASKER

is ok