How do I compare two columns for equality in SQL Server?
问题 I have two columns that are joined together on certain criteria, but I would also like to check two see if two other columns are identical and then return a bit field if they are. Is there a simpler solution than using CASE WHEN? Ideally I could just use: SELECT Column1 = Column2 AS MyDesiredResult FROM Table1 INNER JOIN Table2 ON Table1.PrimaryKey = Table2.ForeignKey 回答1: What's wrong with CASE for this? In order to see the result, you'll need at least a byte, and that's what you get with a