I am attempting to put an IF ELSE statement into the follow SQL Query, but it keeps breaking when I try to execute. I have never used IF ELSE in SQL so I am assuming I am not including it correctly
Query without IF ELSE
UPDATE RA SET
CreditInvoiceAmount = CSV.CreditInvoiceAmount,
CreditInvoiceDate = CSV.CreditInvoiceDate,
CreditInvoiceNumber = CSV.CreditInvoiceNumber,
CreditDeniedDate = CSV.CreditDeniedDate,
CreditDeniedReasonId = CSV.CreditDeniedReasonId,
CreditDeniedNotes = CSV.CreditDeniedNotes
FROM ReturnAuthorization RA
JOIN TemporaryCsvUpload CSV
on RA.Id = CSV.Id
IF ELSE
IF CSV.CreditInvoiceDate = null AND CSV.CreditDeniedDate != null THEN
StatusId = 7;
ELSE
StatusId = 8;
Insert Attempt
UPDATE RA SET
CreditInvoiceAmount = CSV.CreditInvoiceAmount,
CreditInvoiceDate = CSV.CreditInvoiceDate,
CreditInvoiceNumber = CSV.CreditInvoiceNumber,
CreditDeniedDate = CSV.CreditDeniedDate,
CreditDeniedReasonId = CSV.CreditDeniedReasonId,
CreditDeniedNotes = CSV.CreditDeniedNotes,
IF CSV.CreditInvoiceDate = null AND CSV.CreditDeniedDate != null THEN
StatusId = 7;
ELSE
StatusId = 8;
FROM ReturnAuthorization RA
JOIN TemporaryCsvUpload CSV
on RA.Id = CSV.Id
Any guidance on how to correctly put this if statement into the SQL block would be appreciated. Thanks!