Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error: Internal SQL Server error.

Author  Topic 

shifis
Posting Yak Master

157 Posts

Posted - 2006-04-04 : 20:47:21
I am try to run this query but I receive this error:
Server: Msg 8624, Level 16, State 3, Line 1
Internal SQL Server error.


select tbfinal.ASISTENCIA
from
(

select TBRESUMEN.CLA_EMPRESA, TBRESUMEN.NOM_EMPRESA, TBRESUMEN.DELEGACION, TBRESUMEN.TIPO,
TBRESUMEN.CLA_UBICACION_BASE, TBRESUMEN.NOM_UBICACION, TBRESUMEN.CURSO,
COUNT(TBRESUMEN.CLA_TRAB) AS PLATILLA,
SUM( CASE WHEN TBRESUMEN.CALIF<>-1 THEN 1 ELSE 0 END) AS ASISTENCIA,
SUM( CASE WHEN TBRESUMEN.CALIF<>-1 THEN TBRESUMEN.CALIF ELSE 0 END) TOTCALIF
from
(


SELECT TBPLANTILLA.CLA_EMPRESA, TBPLANTILLA.nom_empresa,TBPLANTILLA.DELEGACION, TBPLANTILLA.TIPO, TBPLANTILLA.cla_ubicacion_base,
TBPLANTILLA.nom_ubicacion,
dbo.F_TRIM(replace(replace( substring(nom_curso,5,25),'C.',''),'CURSO', '')) curso,
TBPLANTILLA.CLA_TRAB,
ISNULL(TBCALIF.CALIFICACION,-1) CALIF
From
( select CLA_EMPRESA, dbo.F_TRIM(nom_empresa) AS NOM_EMPRESA, DELEGACION,Case SUBSTRING(SEG_CUENTA, 1, 1) WHEN 'T' THEN 'TIENDA' WHEN 'D' THEN CASE WHEN SUBSTRING(NOM_UBICACION,1,1)='C' THEN 'CEDES'
Else 'DELIFOODS' END WHEN 'C' THEN 'OFICINAS' WHEN NULL THEN 'NONE' WHEN ' ' THEN 'ESPACIO BLANCO' WHEN '' THEN 'NADA' END AS TIPO,
cla_ubicacion_base, nom_ubicacion, CLA_CURSO, NOM_CURSO, cla_trab
From vwcurso_emp as RHTRAB
where RHTRAB.CLA_EMPRESA =1
and rhtrab.cla_ubicacion_base=2
and RHTRAB.CLA_CURSO IN (150,186,180,187) AND RHTRAB.status_TRAB='A' AND RHTRAB.CLA_DEPTO IN (1044,1050,1072)
AND FECHA_ING < CONVERT(DATETIME, '2006-04-04 00:00:00', 102) -9
) TBPLANTILLA
LEFT OUTER JOIN
( SELECT RH_CURSO_TRAB.CLA_EMPRESA, RH_CURSO_TRAB.CLA_TRAB, RH_CURSO_TRAB.CLA_CURSO, RH_CURSO_TRAB.FECHA_ULT_CAMBIO,RH_CURSO_TRAB.calificacion , RH_CURSO_TRAB.folio_curso, RHTRAB.cla_puesto
from RH_CURSO_TRAB inner join RH_TRAB AS RHTRAB on RH_CURSO_TRAB.cla_empresa= RHTRAB.cla_empresa and RH_CURSO_TRAB.cla_trab= RHTRAB.cla_trab
WHERE RHTRAB.CLA_EMPRESA =1 and RH_CURSO_TRAB.CLA_CURSO IN (150,186,180,187) AND RHTRAB.CLA_DEPTO IN (1044,1050,1072)
and RH_CURSO_TRAB.folio_curso= ( select max(r.folio_curso) from RH_CURSO_TRAB r
where r.cla_empresa=RH_CURSO_TRAB.cla_empresa and
r.cla_trab=RH_CURSO_TRAB.cla_trab and r.cla_curso=RH_CURSO_TRAB.cla_curso and
(r.fecha_ult_cambio BETWEEN CONVERT(DATETIME, '1994-01-01 00:00:00', 102) AND CONVERT(DATETIME, '2006-04-04 00:00:00', 102) ) )
) TBCALIF
ON TBPLANTILLA.CLA_EMPRESA = TBCALIF.CLA_EMPRESA AND TBPLANTILLA.CLA_CURSO = TBCALIF.CLA_CURSO AND
TBPLANTILLA.CLA_TRAB = TBCALIF.CLA_TRAB

)TBRESUMEN

GROUP BY
TBRESUMEN.CLA_EMPRESA, TBRESUMEN.NOM_EMPRESA, TBRESUMEN.DELEGACION, TBRESUMEN.TIPO,
TBRESUMEN.CLA_UBICACION_BASE, TBRESUMEN.NOM_UBICACION, TBRESUMEN.CURSO

)tbfinal


I don't know what I receive the error

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-04 : 20:55:33
Derived tables can confuse the compiler. Try recoding the query.
Maybe use a temp table to simplfy it.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -