SCRIPT SQL EXECUTADO NESTA SOLUÇÃO:<br />
<br />
INSERT INTO APARFUN(CODCOLIGADA,CHAPA,CODPARCOL,CODNUCLEO,CODHORREL,VALORDSR,VALORFERIADO,TIPOCARENCIA,CARENCIA,COMPENSACAO,JORNADAPER,DESCANSO,TOLERANCIA,MAXENTSAI,MINJORNADA,USAPONTO,CONSFERIADO,PAGAEXTRA,PAGAADNOTURNO,PAGANONAHORA,PAGAHTRAB,PAGADSR,COMPANUALEXTRA,COMPENSAFALTA,DIADIATOTAL,PRIMEIRAFAIXA,CONSPERCENTUAL,USAEXTRADESC,USAEXTRAFERIADO,MAISOUMENOSBAT,TIPOHORARIO,EXTRAAUTO,AUTORIZADO,ULTIMORECALCULODATA,ULTIMORECALCULOHORA,ARMAZENAEXTRA,ARMAZENACOMP,ARMAZENAEXTRACOMP,ARMAZENAATRASOCOMP,ARMAZENAFALTACOMP,TRABOBRIGFER,USAEXTRACOMP,CONSIDERAHORFLEXDIA,DIAHORFLEX,CODTABFOLGA,LIMITECOMPFLEX,DIADIATOTALCOMP,DIADIATOTALDESC,DIADIATOTALFER,ABATECARENCIA,TEMPOMINJOR,CODTABPONTE,VALORDSRPROPORC,TEMPPARFUN,CONSCALCJORNADA,VISMOVCONJORFUN,JORNADA,TIPOJORNADA,INTREFEICAO,NUMPARBAT,TOLEXTRAS,ABATTOLEXTRAS,TOLATRASOS,ABATTOLATRASOS,REDUZHORNOT,FORMULAJOR,DATAINICIOPERIODOTRANSICAO,CARENCIAEXTRAAPOSCOMP,CARENCIAATRASOAPOSCOMP,CONSIDERAHORARIOCHRONUSPROF,RECCREATEDBY,RECCREATEDON,RECMODIFIEDBY,RECMODIFIEDON,CONSIDERAINICIODEFINIRJORNADA,TEMPOCONTJORNADA,TEMPOACRESCDEFJORNSEMTRAB,CONSIDERAJORNSEMTRABCONTINUAS,TEMPOACRESCLIMJORNTRAB,TOTALIZAOCORRENCIACOMPESP,CONSFAIXAEXTRA)<br />
SELECT distinct A.CODCOLIGADA,A.CHAPA,E.CODPARCOL,E.CODNUCLEO,E.CODHORREL,E.VALORDSR,VALORFERIADO,TIPOCARENCIA,CARENCIA,COMPENSACAO,JORNADAPER,DESCANSO,TOLERANCIA,MAXENTSAI,MINJORNADA,USAPONTO,CONSFERIADO,PAGAEXTRA,PAGAADNOTURNO,PAGANONAHORA,PAGAHTRAB,PAGADSR,COMPANUALEXTRA,COMPENSAFALTA,DIADIATOTAL,PRIMEIRAFAIXA,CONSPERCENTUAL,USAEXTRADESC,USAEXTRAFERIADO,MAISOUMENOSBAT,TIPOHORARIO,EXTRAAUTO,AUTORIZADO,A.ULTIMORECALCULODATA,A.ULTIMORECALCULOHORA,ARMAZENAEXTRA,ARMAZENACOMP,ARMAZENAEXTRACOMP,ARMAZENAATRASOCOMP,ARMAZENAFALTACOMP,TRABOBRIGFER,USAEXTRACOMP,CONSIDERAHORFLEXDIA,DIAHORFLEX,CODTABFOLGA,LIMITECOMPFLEX,DIADIATOTALCOMP,DIADIATOTALDESC,DIADIATOTALFER,ABATECARENCIA,TEMPOMINJOR,CODTABPONTE,VALORDSRPROPORC,TEMPPARFUN,CONSCALCJORNADA,VISMOVCONJORFUN,A.JORNADA,TIPOJORNADA,INTREFEICAO,NUMPARBAT,TOLEXTRAS,ABATTOLEXTRAS,TOLATRASOS,ABATTOLATRASOS,REDUZHORNOT,FORMULAJOR,DATAINICIOPERIODOTRANSICAO,CARENCIAEXTRAAPOSCOMP,CARENCIAATRASOAPOSCOMP,CONSIDERAHORARIOCHRONUSPROF, 'system' 'RECCREATEDBY',GETDATE() 'RECCREATEDON', 'system' 'RECMODIFIEDBY', GETDATE() 'RECMODIFIEDON',CONSIDERAINICIODEFINIRJORNADA,TEMPOCONTJORNADA,TEMPOACRESCDEFJORNSEMTRAB,CONSIDERAJORNSEMTRABCONTINUAS,TEMPOACRESCLIMJORNTRAB,TOTALIZAOCORRENCIACOMPESP,CONSFAIXAEXTRA<br />
FROM PFUNC A (NOLOCK)<br />
INNER JOIN PFUNC B (NOLOCK) ON(B.CODPESSOA=A.CODPESSOA AND B.TIPODEMISSAO='5' AND B.DATADEMISSAO BETWEEN '01/03/2025' AND '31/03/2025')<br />
INNER JOIN PFUNCAO C (NOLOCK) ON(C.CODCOLIGADA=A.CODCOLIGADA AND C.CODIGO=A.CODFUNCAO)<br />
INNER JOIN ABATFUN D (NOLOCK) ON(D.CODCOLIGADA=B.CODCOLIGADA AND D.CHAPA=B.CHAPA AND D.DATA BETWEEN '26/02/2025' AND '25/03/2025')<br />
INNER JOIN APARFUN E (NOLOCK) ON(E.CODCOLIGADA=B.CODCOLIGADA AND E.CHAPA=B.CHAPA)<br />
WHERE A.DTTRANSFERENCIA  BETWEEN '01/03/2025' AND '31/03/2025'<br />
AND NOT EXISTS(SELECT X.CODCOLIGADA, X.CHAPA  FROM APARFUN X (NOLOCK) WHERE X.CODCOLIGADA=A.CODCOLIGADA AND X.CHAPA=A.CHAPA)<br />
<br />
INSERT INTO ABATFUN(CODCOLIGADA,CHAPA,DATA,BATIDA,STATUS,NATUREZA,DATAINSERCAO,DATAREFERENCIA,IDJORNADA,RECCREATEDBY,RECCREATEDON,RECMODIFIEDBY,RECMODIFIEDON)<br />
SELECT DISTINCT A.CODCOLIGADA,A.CHAPA,D.DATA,D.BATIDA,D.STATUS,D.NATUREZA,D.DATAINSERCAO,D.DATAREFERENCIA,NULL 'IDJORNADA','system' 'RECCREATEDBY',GETDATE() 'RECCREATEDON', 'system' 'RECMODIFIEDBY', GETDATE() 'RECMODIFIEDON'<br />
FROM PFUNC A (NOLOCK)<br />
INNER JOIN PFUNC B (NOLOCK) ON(B.CODPESSOA=A.CODPESSOA AND B.TIPODEMISSAO='5' AND B.DATADEMISSAO BETWEEN '01/03/2025' AND '31/03/2025')<br />
INNER JOIN PFUNCAO C (NOLOCK) ON(C.CODCOLIGADA=A.CODCOLIGADA AND C.CODIGO=A.CODFUNCAO)<br />
INNER JOIN ABATFUN D (NOLOCK) ON(D.CODCOLIGADA=B.CODCOLIGADA AND D.CHAPA=B.CHAPA AND D.DATA BETWEEN '26/02/2025' AND '25/03/2025')<br />
WHERE A.DTTRANSFERENCIA  BETWEEN '01/03/2025' AND '31/03/2025'<br />
AND NOT EXISTS(SELECT X.CODCOLIGADA, X.CHAPA, X.BATIDA FROM ABATFUN X (NOLOCK) WHERE X.CODCOLIGADA=A.CODCOLIGADA AND X.CHAPA=A.CHAPA AND X.BATIDA=D.BATIDA)<br />
<br />
INSERT INTO AABONFUN(CODCOLIGADA,CHAPA,DATA,CODABONO,HORAINICIO,HORAFIM,DESCONSIDERA,RESPONSAVEL,ABONOFUTURO,COLIGADARESP,SOLUCAOCONFLITO,RECCREATEDBY,RECCREATEDON,RECMODIFIEDBY,RECMODIFIEDON,JUSTIFICATIVA)<br />
SELECT DISTINCT A.CODCOLIGADA,A.CHAPA,E.DATA, E.CODABONO, E.HORAINICIO,E.HORAFIM, E.DESCONSIDERA, E.RESPONSAVEL, E.ABONOFUTURO, E.COLIGADARESP, E.SOLUCAOCONFLITO  , 'system' 'RECCREATEDBY', GETDATE() 'RECCREATEDON', 'system' 'RECMODIFIEDBY', GETDATE() 'RECMODIFIEDON', E.JUSTIFICATIVA<br />
FROM PFUNC A (NOLOCK)<br />
INNER JOIN PFUNC B (NOLOCK) ON(B.CODPESSOA=A.CODPESSOA AND B.TIPODEMISSAO='5' AND B.DATADEMISSAO BETWEEN '01/03/2025' AND '31/03/2025')<br />
INNER JOIN PFUNCAO C (NOLOCK) ON(C.CODCOLIGADA=A.CODCOLIGADA AND C.CODIGO=A.CODFUNCAO)<br />
INNER JOIN AABONFUN E (NOLOCK) ON(E.CODCOLIGADA=B.CODCOLIGADA AND E.CHAPA=B.CHAPA AND E.DATA BETWEEN '26/02/2025' AND '25/03/2025')<br />
WHERE A.DTTRANSFERENCIA  BETWEEN '01/03/2025' AND '31/03/2025'<br />
AND NOT EXISTS(SELECT X.CODCOLIGADA, X.CHAPA, X.DATA, X.CODABONO, X.HORAINICIO FROM AABONFUN X (NOLOCK) WHERE X.CODCOLIGADA=A.CODCOLIGADA AND X.CHAPA=A.CHAPA AND X.CODABONO=E.CODABONO AND X.DATA=E.DATA and X.HORAINICIO=E.HORAINICIO and X.HORAFIM=E.HORAFIM)<br />
<br />
INSERT INTO PFUNCVAL<br />
SELECT DISTINCT A.CODCOLIGADA,A.CHAPA,E.CODVALOR, E.DTVALOR, E.VALOR,E.OBSERVACAO,'system' 'RECCREATEDBY',GETDATE() 'RECCREATEDON', 'system' 'RECMODIFIEDBY', GETDATE() 'RECMODIFIEDON'<br />
FROM PFUNC A (NOLOCK)<br />
INNER JOIN PFUNC B (NOLOCK) ON(B.CODPESSOA=A.CODPESSOA AND B.TIPODEMISSAO='5' AND B.DATADEMISSAO BETWEEN '01/03/2025' AND '31/03/2025')<br />
INNER JOIN PFUNCAO C (NOLOCK) ON(C.CODCOLIGADA=A.CODCOLIGADA AND C.CODIGO=A.CODFUNCAO)<br />
INNER JOIN PFUNCVAL E (NOLOCK) ON(E.CODCOLIGADA=B.CODCOLIGADA AND E.CHAPA=B.CHAPA AND E.DTVALOR BETWEEN '26/02/2025' AND '25/03/2025')<br />
WHERE A.DTTRANSFERENCIA  BETWEEN '01/03/2025' AND '31/03/2025'<br />
AND NOT EXISTS(SELECT X.CODCOLIGADA, X.CHAPA, X.DTVALOR, X.CODVALOR FROM PFUNCVAL X (NOLOCK) WHERE X.CODCOLIGADA=A.CODCOLIGADA AND X.CHAPA=A.CHAPA AND X.CODVALOR=E.CODVALOR AND X.DTVALOR=E.DTVALOR)<br />
<br />
INSERT INTO PFRATEIOFIXO(CODCOLIGADA,CHAPA,CODCCUSTO,VALOR,RECCREATEDBY,RECCREATEDON,RECMODIFIEDBY,RECMODIFIEDON)<br />
SELECT DISTINCT A.CODCOLIGADA,A.CHAPA, E.CODCCUSTO, E.VALOR , 'system' 'RECCREATEDBY', GETDATE() 'RECCREATEDON', 'system' 'RECMODIFIEDBY', GETDATE() 'RECMODIFIEDON'<br />
FROM PFUNC A (NOLOCK)<br />
INNER JOIN PFUNC B (NOLOCK) ON(B.CODPESSOA=A.CODPESSOA AND B.TIPODEMISSAO='5' AND B.DATADEMISSAO BETWEEN '01/03/2025' AND '31/03/2025')<br />
INNER JOIN PFUNCAO C (NOLOCK) ON(C.CODCOLIGADA=A.CODCOLIGADA AND C.CODIGO=A.CODFUNCAO)<br />
INNER JOIN PFRATEIOFIXO E (NOLOCK) ON(E.CODCOLIGADA=B.CODCOLIGADA AND E.CHAPA=B.CHAPA) <br />
WHERE A.DTTRANSFERENCIA  BETWEEN '01/03/2025' AND '31/03/2025'<br />
AND NOT EXISTS(SELECT X.CODCOLIGADA, X.CHAPA FROM PFRATEIOFIXO X (NOLOCK) WHERE X.CODCOLIGADA=A.CODCOLIGADA AND X.CHAPA=A.CHAPA)