Tengo un problema con un query, al solicitar los datos me manda el error siguiente:
Conversion failed when converting the varchar value '0R' to data type int.
Ya realice un chequeo a mi DB, no este con problemas y no manda errores detectados,
lo curioso es que la semana pasaba no me mandaba este problema usando el mismo query.
Este es el query que estoy usando:
Código SQL:
Ver original
SELECT MINVE01.NUM_MOV, MINVE01.CVE_ART, INVE01.DESCR, CASE MINVE01.CVE_CPTO WHEN 51 THEN MINVE01.CANT * - 1 WHEN 56 THEN MINVE01.CANT * - 1 ELSE MINVE01.CANT END AS CANTIDAD, MINVE01.CVE_CPTO, CONVERT(CHAR(12), MINVE01.FECHA_DOCU, 106) AS FECHA, MINVE01.PRECIO, CLIE01.CLASIFIC, CLIE01.CLAVE, CLIE01.NOMBRE, VEND01.CVE_VEND, CASE MINVE01.CVE_CPTO WHEN 51 THEN MINVE01.CANT * - 1 * MINVE01.PRECIO WHEN 56 THEN MINVE01.CANT * - 1 * MINVE01.PRECIO ELSE MINVE01.CANT * MINVE01.PRECIO END AS IMPORTE, SUBSTRING(CLIE01.CLASIFIC, 4, 1) AS CANAL, SUBSTRING(CLIE01.CLASIFIC, 5, 1) AS POF, CONVERT(CHAR(3), MINVE01.FECHA_DOCU, 109) AS MES, VEND01.NOMBRE AS VENDE, SUBSTRING(CLIE01.CLASIFIC, 1, 2) AS ESTADO, CASE SUBSTRING(CLIE01.CLASIFIC, 1, 2) WHEN 01 THEN 'Aguascalientes' WHEN 02 THEN 'Baja California Norte' WHEN 03 THEN 'Baja California Sur' WHEN 04 THEN 'Campeche' WHEN 05 THEN 'Coahuila' WHEN 06 THEN 'Colima' WHEN 07 THEN 'Chiapas' WHEN 08 THEN 'Chihuahua' WHEN 09 THEN 'Distrito Federal' WHEN 10 THEN 'Durango' WHEN 11 THEN 'Guanajuato' WHEN 12 THEN 'Guerrero' WHEN 13 THEN 'Hidalgo' WHEN 14 THEN 'Jalisco' WHEN 15 THEN 'Estado de Mexico' WHEN 16 THEN 'Michoacan' WHEN 17 THEN 'Morelos' WHEN 18 THEN 'Nayarit' WHEN 19 THEN 'Nuevo leon' WHEN 20 THEN 'Oaxaca' WHEN 21 THEN 'Puebla' WHEN 22 THEN 'Queretaro' WHEN 23 THEN 'Quintana Roo' WHEN 24 THEN 'San Luis Potosi' WHEN 25 THEN 'Sinaloa' WHEN 26 THEN 'Sonora' WHEN 27 THEN 'Tabasco' WHEN 28 THEN 'Tamaulipas' WHEN 29 THEN 'Tlaxcala' WHEN 30 THEN 'Veracruz' WHEN 31 THEN 'Yucatan' WHEN 32 THEN 'Zacatecas' WHEN 33 THEN 'Extranjeros' ELSE 'x' END AS DESTADO, SUBSTRING(CLIE01.CLASIFIC, 4, 1) AS TIPOC, CASE SUBSTRING(CLIE01.CLASIFIC, 4, 1) WHEN 'A' THEN 'Autoservicios' WHEN 'C' THEN 'Centros de Consumo' WHEN 'D' THEN 'Detallistas' WHEN 'E' THEN 'Otros' WHEN 'F' THEN 'Personas Fisicas' WHEN 'H' THEN 'Hoteles' WHEN 'I' THEN 'Institucionales' WHEN 'M' THEN 'Mayoristas' WHEN 'O' THEN 'Otros' WHEN 'R' THEN 'Restaurantes' WHEN 'S' THEN 'Otros' WHEN 'V' THEN 'Departamentales' WHEN 'X' THEN 'Otros' ELSE 'x' END AS TICLIENTE, CASE VEND01.CLASIFIC WHEN 'A' THEN 'Autoservicios' WHEN 'P' THEN 'Plaza' WHEN 'D' THEN 'Directos Plaza' ELSE 'Foraneo' END AS DCANAL, INVE01.UNI_EMP AS UNIXCAJA, CASE MINVE01.CVE_CPTO WHEN 51 THEN (MINVE01.CANT / INVE01.UNI_EMP) ELSE (MINVE01.CANT / INVE01.UNI_EMP)* -1 END AS CAJAS, CONVERT(CHAR(4), MINVE01.FECHA_DOCU, 102) AS ANI FROM CLIE01 RIGHT OUTER JOIN VEND01 RIGHT OUTER JOIN MINVE01 ON VEND01.CVE_VEND = MINVE01.VEND ON CLIE01.CLAVE = MINVE01.CLAVE_CLPV LEFT OUTER JOIN INVE01 ON MINVE01.CVE_ART = INVE01.CVE_ART WHERE ((MINVE01.FECHA_DOCU >= '2014-08-01') AND (MINVE01.FECHA_DOCU <= '2014-08-26') AND (MINVE01.CVE_CPTO = 4 OR MINVE01.CVE_CPTO = 51 OR MINVE01.CVE_CPTO = 56 OR MINVE01.CVE_CPTO = 2) AND INVE01.UNI_EMP > 0) ORDER BY MINVE01.NUM_MOV
De antemano gracias por el apoyo