Discussion Locked

Compare 2 fields Data base

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How can i compare 2 fields in a SQL server Database?

2 replies

by tink

Two fields on the same table:
SELECT *
FROM MyTab
WHERE ISNULL (Col1, '*') <> ISNULL (Col2, '*')

Two fields from two different tables:
SELECT Tab1.ID, Tab1.Col, Tab2.Col
FROM Tab1, Tab2
WHERE Tab1.ID = Tab2.ID AND
ISNULL (Tab1.Col, '*') <>ISNULL (Tab2.Col, '*')

This discussion is closed to new replies.