Skip to content
Advertisement

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 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:

Advertisement

Answer

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 single character.

should work fine, and for all intents and purposes accomplishes the same thing as using a bit field.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement