If you’re getting an error that reads something like “The objects “employees” and “employees” in the FROM clause have the same exposed names. Use correlation names to distinguish them’” in SQL Server, it could be that you’re trying to do a self-join without assigning table aliases.
When doing self-joins, we need to provide aliases for the tables so that SQL Server can distinguish between each instance.
To fix this issue, be sure to use unique table aliases in your query.
Continue reading