I am not sure what this is supposed to do:
Code:
A.ENTITYID + Cast(VARCHAR(10),A.ENTERDAT)
I have never seen such a "Cast" syntax. If it means that A.ENTERDAT should be cast to VARCHAR(10), the syntax should be:
Code:
CAST(a.enterdat AS VARCHAR(10))
Aside from that, you try to
add a string to something else. I guess you may want to use the CONCAT or '||' operators because those are the standard SQL constructs for string concatenation.