SQLTeam.com | Weblogs | Forums

Adding dash to cast(concat) function


#1

Hello everyone,
I've got the following code snippet, and I would like to add a dash in order to separate the two values. Every method I've tried has failed, and I was hoping someone might be able to assist me with this issue. The code snippet is:

case
when a.[CSGSYS] = 8495 THEN CAST(CONCAT(a.[CSGSYS], a.[CSGPRIN]) AS INT)
else a.[CSGSYS]
end as 'SYS_PRIN'

Any assistance anyone can give me is greatly appreciated. Thank you.

Damian


#2
CASE
	WHEN a.[CSGSYS] = 8495 THEN
		CONCAT(a.[CSGSYS],'-', a.[CSGPRIN])
	ELSE
		CAST(a.[CSGSYS] AS VARCHAR(32))
END AS 'SYS_PRIN'

#3

Thank you so much JamesK, that worked like a charm!