Código sql:
Ver originalCREATE PROCEDURE miProcedimiento
@idPersonal INT,
@nombre nvarchar(100)
AS
EXEC('
select DL.diaSemana,DL.horainicio,DL.horafin, CL.*
from tblCliente as CL
inner join tbldiaslimpieza as DL on CL.IdCliente=DL.IdCliente
left join tblPersonalDiasLimpieza as PDL on DL.IddiasLimpieza=PDL.iddiaslimpieza
where Empresa LIKE '''+@nombre +'''% and ('+CAST(@idPersonal AS VARCHAR)+' is null or IdPersonal<>'+CAST(@idPersonal AS VARCHAR))