With transact-sql (t-sql) I have a string constant and three string variables I want to Concatenate with a semicolon delimiter between each value. Each of the three string variables are sometimes blank or null, which creates situations where there is one, two, or three semicolon delimiters that I don't want.
I tried Concat_ws() function which is supposed to work according to t-sql websites, but I get error message saying not a recognized function name. I tried two statements with Replace() function where I replace double or triple semicolons with blanks instead. That works but seems crude and won't help me replace just one trailing semicolon. Any ideas?
Sample code that produces too many semicolons when a var is blank:
Concat('Label ', ';', var1, ';', var2, ';', var3) as Result