Before someone starts saying that this table needs to be normalized, best practices, etc. I agree that this is an old table that we have in SQL Server 2008 R2, and I can do nothing about it. Having said that, this table has the following columns:
"PreparedBy", "PrelimApprovalBy", "Approval1Signer", "Approval2Signer"
All of these fields have either usernames, either NULL or ``. I want to get all the lines in which the same username appears in 2 OR MORE fields mentioned above. If 2 fields are NULL, they correspond to NOT , and they correspond to NOT if they are both characters. '' Therefore, both NULL and βneedβ are excluded, because they mean nothing.
HERE THAT I THINK SO FURTHER BUT DO NOT LIKE:
I mean checking all permutations in the WHERE clause (checking for NULL and ") by doing something line by line
WHERE PreparedBy = PrelimApprovalBy OR PreparedBy = Approval1Signer OR ...
There must be a better way to do this.
sql sql-server tsql
Denis
source share