Hola a todos, una consulta,
necesito poner la siguiente Query en un SP y no puedo, no me deja grabarlo,
desde el Query Analizer la consulta funciona perfecto, pero no la puedo
meter en un SP, y lo necesito para poder invocarla desde una planilla de
Excel
La Comprobación de sintaxis no me da error, pero al querer grabar el SP me
da lo siguiente:
"Microsoft SQL-DMO (ODBC SQLState: 42000)
Error 2714: El procedimiento aa_CCFir, número de grupo 1, ya existe en la
base de datos. Elija otro nombre de procedimiento"
El tema es que aunque le cambie el nombre, me sigue diciendo lo mismo.
Alguien sabe que puedo estar haciendo mal?
Abajo les copio el código que pongo dentro del SP
Saludos y muchas gracias de antemano
Pablo
CREATE PROCEDURE aa_CCFir AS
IF OBJECT_ID('USR_CCFIRA') IS NOT NULL
DROP TABLE USR_CCFIRA
GO
CREATE TABLE USR_CCFIRA
(USR_CCFIRA_FCHMOV datetime NOT NULL, USR_CCFIRA_NROFOR int NOT NULL,
USR_CCFIRA_CODFOR varchar(6) NOT NULL, USR_CCFIRA_CHEQUE int NOT NULL,
USR_CCFIRA_IMPORT float(18) NOT NULL,
PRIMARY KEY (USR_CCFIRA_FCHMOV, USR_CCFIRA_CODFOR, USR_CCFIRA_NROFOR,
USR_CCFIRA_CHEQUE, USR_CCFIRA_IMPORT )
)
GO
INSERT INTO USR_CCFIRA
( USR_CCFIRA_CODFOR, USR_CCFIRA_NROFOR, USR_CCFIRA_CHEQUE,
USR_CCFIRA_FCHMOV, USR_CCFIRA_IMPORT)
SELECT PVRMVC_CODFOR, PVRMVC_NROFOR, "0", PVRMVC_FCHVNC, PVRMVC_IMPNAC *-1
FROM PVRMVC
WHERE (PVRMVC_NROCTA='MFIRAR')and PVRMVC_CODFOR <> 'OP' and PVRMVC_CODFOR <>
'AOP'
ORDER BY PVRMVC_FCHMOV
GO
INSERT INTO USR_CCFIRA
( USR_CCFIRA_CODFOR, USR_CCFIRA_NROFOR, USR_CCFIRA_CHEQUE,
USR_CCFIRA_FCHMOV, USR_CCFIRA_IMPORT)
select cjrmvi_codfor, cjrmvi_nrofor, CJRMVI_CHEQUE, CJRMVI_FCHAUX,
case CJRMVI_debhab when 'd' then cjrmvi_import else cjrmvi_import * -1 end
from cjrmvi, cjrmvh
where cjrmvh_nrocpv = 'mfirar' and cjrmvi_modfor = cjrmvh_modfor and
cjrmvi_codfor = cjrmvh_codfor and cjrmvi_nrofor = cjrmvh_nrofor and
((cjrmvi_codfor = 'op' and cjrmvi_debhab = 'h') or (cjrmvi_codfor =
'aop' and cjrmvi_debhab = 'd'))
order by cjrmvi_fchAUX
GO
SELECT *
FROM USR_CCFIRA
ORDER BY USR_CCFIRA_FCHMOV, USR_CCFIRA_CODFOR, USR_CCFIRA_NROFOR,
USR_CCFIRA_CHEQUE, USR_CCFIRA_IMPORT
Leer las respuestas