is there an alternative to using cross join in a sql query?

Your query is fine. It can be written using a JOIN:

SELECT p.PersonID, md.DateVal
FROM Person p JOIN
     MissingDates md
     ON md.DateVal >= p.StartDate AND md.DateVal <= p.EndDate;

Your results suggest that you want equality.

Note: The above is going to generate the same execution plan as your query. It gets rid of the CROSS JOIN, but that will probably not affect performance.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top