Hi i have a query in Access which i need to work in SSMS/SQLServer. The IF statement in the join does not work due to the operators ">=" in the last AND JOIN. Any ideas how else i can do this in SQLServer
SELECT
TABLEA.Dates,
TABLEA.CAR_ID,
TABLEB.Model_ID,
TABLEB.TYPE_ID
FROM TABLEA
LEFT JOIN TABLEB
ON (TABLEA.CAR_ID = TABLEB.CAR_ID)
AND
iif(B.Role_End_Date is null,
(TABLEA.Dates >= TABLEB.SDate) ,
(TABLEA.Dates >= TABLEB.SDate)
AND (TABLEA.Dates <= TABLEB.EDate) )
SELECT
TABLEA.Dates,
TABLEA.CAR_ID,
TABLEB.Model_ID,
TABLEB.TYPE_ID
FROM TABLEA
LEFT JOIN TABLEB
ON (TABLEA.CAR_ID = TABLEB.CAR_ID)
AND
iif(B.Role_End_Date is null,
(TABLEA.Dates >= TABLEB.SDate) ,
(TABLEA.Dates >= TABLEB.SDate)
AND (TABLEA.Dates <= TABLEB.EDate) )