I'm curious to see if anyone can suggest a good way to maintain good domain integrity on sql server that will stop or warn user's if they try to join incompatible fields with the same data types.
Select ORDER_ID, CUSTOMER_ID
FROM ORDERS o
INNER JOIN CUSTOMERS c
ON o.ORDER_ID = c.Customer_ID
This query clearly doesn't make sense as orders are not customers but SQL server will allow it if the data types are the same. Hence is there a good way to warn or prevent users from doing such queries?