Reputation: 9960
This code:
select right('XXXXXXXXXXX' + 'BARCGB22', 11)
Results in: "XXXBARCGB22"
But I need the reversed and I'm having a hard time doing it. It needs to be:
"BARCGB22XXX"
Can anyone give me a quick hand?
Thanks
Upvotes: 0
Views: 67
Reputation: 4786
I'm assuming BARCGB22
will be coming from a variable. I'd use SELECT left(coalesce(myvar,'')+'XXXXXXXXXXX', 11)
. `NULL' kinda has a special meaning and it behaves a bit different from a normal variable.
EDIT:
Or '...isNull(myvar,'')....
isNull()and
coalesce()do just about the same thing, but
isNullis T-SQL while
coalesce` is more generic.
Upvotes: 4