Al tratar de crear dinamicamente el siguiente SQL, el servidor me arroja
este error:
Error de sintaxis al convertir una cadena de caracteres a datetime
este es el SQL:
set @sql = N'SELECT htDetalleNormal.Lun, htDetalleNormal.Mar,
htDetalleNormal.Mie, htDetalleNormal.Jue, htDetalleNormal.Vie,
htDetalleNormal.HojaId, ' +
'htDetalleNormal.FechaMie AS Desde, htDetalleNormal.FechaMie AS Hasta
' +
'FROM personal FULL OUTER JOIN ' +
'Clasificacion ON personal.ClasificacionId Clasificacion.ClasificacionId FULL OUTER JOIN ' +
'Hojatiempo ON personal.CedulaId = Hojatiempo.CedulaId FULL
OUTER JOIN ' +
'htDetalleNormal ON Hojatiempo.HojaId = htDetalleNormal.HojaId '
+
'WHERE ' + (COL_NAME(OBJECT_ID('dbo.HtDetalleNormal'),@Desde) + ' >= ' +
CONVERT(DATETIME,@FDesde, 102)) + 'AND ' +
(COL_NAME(OBJECT_ID('dbo.HtDetalleNormal'),@Hasta) + ' <= ' +
CONVERT(DATETIME,@FHasta, 102)) + ' for browse'
Gracias de antemano.
Mario
Leer las respuestas