
Error en cursor
Publicado por Hector (7 intervenciones) el 23/10/2008 16:49:09
Hola a todos , estoy haciendo un cursor que recupere todos los campos de una tabla, y que para cada campo actualize los registros que contienen '.' , cuando lo ejecuto me dice que no se efectuaron cambios en ninguna fila. El codigo es el siguiente.
DECLARE @CAMPO VARCHAR(255)
DECLARE ELIMINAR_PUNTOS CURSOR
FOR
SELECT COLUMN_NAME from information_schema.columns
INNER JOIN
information_schema.tables
ON
information_schema.tables.TABLE_NAME = information_schema.columns.TABLE_NAME
WHERE information_schema.tables.TABLE_NAME= 'CG_10';
OPEN ELIMINAR_PUNTOS
FETCH ELIMINAR_PUNTOS INTO @CAMPO
WHILE (@@FETCH_STATUS = 0)
BEGIN
PRINT @CAMPO
-- Supongo que aqui esta el error.
UPDATE CG_10 SET @CAMPO= NULL WHERE @CAMPO='.' ;
FETCH ELIMINAR_PUNTOS INTO @CAMPO
END
CLOSE ELIMINAR_PUNTOs
DEALLOCATE ELIMINAR_PUNTOS
El resultado es el siguiente:
P6016
(0 row(s) affected)
P6020
(0 row(s) affected)
P6030
(0 row(s) affected)
P6040
(0 row(s) affected)
P6050
(0 row(s) affected)
P6080
(0 row(s) affected)
P6080S1
(0 row(s) affected)
P6060
(0 row(s) affected)
P6060S1
(0 row(s) affected)
P6070
(0 row(s) affected)
P6090
(0 row(s) affected)
P6140
(0 row(s) affected)
P6150
(0 row(s) affected)
P6100
(0 row(s) affected)
P6110
(0 row(s) affected)
P6120
(0 row(s) affected)
P6125
(0 row(s) affected)
P6160
(0 row(s) affected)
P6170
(0 row(s) affected)
P6175
(0 row(s) affected)
P6180
(0 row(s) affected)
P6180S1
(0 row(s) affected)
P6180S2
(0 row(s) affected)
P6190
(0 row(s) affected)
P6190S1
(0 row(s) affected)
P6200
(0 row(s) affected)
P6200S1
(0 row(s) affected)
P6210
(0 row(s) affected)
P6210S1
(0 row(s) affected)
P6220
(0 row(s) affected)
RC1
(0 row(s) affected)
RC2
(0 row(s) affected)
RC3
(0 row(s) affected)
RC4
(0 row(s) affected)
RC5
(0 row(s) affected)
RC12
(0 row(s) affected)
RC13
(0 row(s) affected)
RC17
(0 row(s) affected)
RC18
(0 row(s) affected)
RC19
(0 row(s) affected)
RC20
(0 row(s) affected)
RC21
(0 row(s) affected)
RC22
(0 row(s) affected)
RC23
(0 row(s) affected)
ID
(0 row(s) affected)
DECLARE @CAMPO VARCHAR(255)
DECLARE ELIMINAR_PUNTOS CURSOR
FOR
SELECT COLUMN_NAME from information_schema.columns
INNER JOIN
information_schema.tables
ON
information_schema.tables.TABLE_NAME = information_schema.columns.TABLE_NAME
WHERE information_schema.tables.TABLE_NAME= 'CG_10';
OPEN ELIMINAR_PUNTOS
FETCH ELIMINAR_PUNTOS INTO @CAMPO
WHILE (@@FETCH_STATUS = 0)
BEGIN
PRINT @CAMPO
-- Supongo que aqui esta el error.
UPDATE CG_10 SET @CAMPO= NULL WHERE @CAMPO='.' ;
FETCH ELIMINAR_PUNTOS INTO @CAMPO
END
CLOSE ELIMINAR_PUNTOs
DEALLOCATE ELIMINAR_PUNTOS
El resultado es el siguiente:
P6016
(0 row(s) affected)
P6020
(0 row(s) affected)
P6030
(0 row(s) affected)
P6040
(0 row(s) affected)
P6050
(0 row(s) affected)
P6080
(0 row(s) affected)
P6080S1
(0 row(s) affected)
P6060
(0 row(s) affected)
P6060S1
(0 row(s) affected)
P6070
(0 row(s) affected)
P6090
(0 row(s) affected)
P6140
(0 row(s) affected)
P6150
(0 row(s) affected)
P6100
(0 row(s) affected)
P6110
(0 row(s) affected)
P6120
(0 row(s) affected)
P6125
(0 row(s) affected)
P6160
(0 row(s) affected)
P6170
(0 row(s) affected)
P6175
(0 row(s) affected)
P6180
(0 row(s) affected)
P6180S1
(0 row(s) affected)
P6180S2
(0 row(s) affected)
P6190
(0 row(s) affected)
P6190S1
(0 row(s) affected)
P6200
(0 row(s) affected)
P6200S1
(0 row(s) affected)
P6210
(0 row(s) affected)
P6210S1
(0 row(s) affected)
P6220
(0 row(s) affected)
RC1
(0 row(s) affected)
RC2
(0 row(s) affected)
RC3
(0 row(s) affected)
RC4
(0 row(s) affected)
RC5
(0 row(s) affected)
RC12
(0 row(s) affected)
RC13
(0 row(s) affected)
RC17
(0 row(s) affected)
RC18
(0 row(s) affected)
RC19
(0 row(s) affected)
RC20
(0 row(s) affected)
RC21
(0 row(s) affected)
RC22
(0 row(s) affected)
RC23
(0 row(s) affected)
ID
(0 row(s) affected)
Valora esta pregunta


0