I have the following table:
ApprovalOrder EntityCode ProjectCode
1 1415 NULL
2 1415 NULL
3 1415 NULL
And the following code:
select
de.ApprovalOrder + de. EntityCode + isnull(de.ProjectCode, '') as 'RowID'
from workflow.delegation_engine de
where EntityCode = 1415 and DelegationCode = 'CAT1'
Which is unfortunately returning an additive result. I’m aware this is what it should do given the above however how can I make it concatenate the result of each column into one result whilst also only including de.ProjectCode when the result it not NULL (this can be characters or integer values).
For example, if I was running query just on the first row of this table I’d like the returned result to be ‘11415’.
To be explicit about what you are doing, I would cast each item to a VARCHAR() first.
If you want a hack to avoid the explicit casting, start the derivation with a string…