You need to either use express in the WHERE or use your SELECT query as a subquery, for example:
select * from ( select cast(de.ApprovalOrder AS VARCHAR(32)) + cast(de.EntityCode AS VARCHAR(32)) + isnull(cast(de.DelegationCode AS VARCHAR(32)), '') as RowID, * from workflow.delegation_engine de ) where RowID is not NULL
Or, the sloppier route (in my opinion) would be:
select cast(de.ApprovalOrder AS VARCHAR(32)) + cast(de.EntityCode AS VARCHAR(32)) + isnull(cast(de.DelegationCode AS VARCHAR(32)), '') as RowID, * from workflow.delegation_engine de where cast(de.ApprovalOrder AS VARCHAR(32)) + cast(de.EntityCode AS VARCHAR(32)) + isnull(cast(de.DelegationCode AS VARCHAR(32)), '') is not null
I would go with the first solution every time.
Also note that I changed the WHERE from
RowID <> NULL
For
RowID is not NULL
This is because <> NULL will never evaluate to true. SQL Server tests for NULL (i.e., Unknown) using IS and IS NOT .
user596075
source share