I have a SQL Server table called DM_Time. Her fields are:
DtRef
AnoRef
MesRef
DiaRef
MesExtenso
CodDiaSemana
SemanaNumero
IndFeriado
And they already have in it days marked as holidays (in this case, IndFeriado = 'YES'). But what I was wanting to do was the following, for example: if a date that was on a Friday (CodDiaSemana = 6) is not a holiday, but the day before was, I have to do an UPDATE for that Friday to be considered a holiday also (type a holiday). I tried something like this:
UPDATE DM_Tempo
SET IndFeriado = 'SIM'
WHERE AnoRef IN (2017,2018)
AND IndFeriado = 'NÃO'
AND CodDiaSemana = 6
AND IndFeriado IN (
SELECT IndFeriado FROM DM_TempoEmpresa T2 WHERE T2.DtRef =
DATEADD(DAY,-1,T1.DtRef) AND T2.IndFeriado = 'SIM'
)
order by 2,1
But it did not work. What would you do?