gerard-593414 (8/5/2012)
I am trying to use a variabe to camcattenate a stringI use following:
DECLARE @MYVAR Char(1000) = 'INITIAL'
if Conditon 1
SET @MYVAR = @MYVAR + ' ABC'
If Condition 2
SET @MYVAR = @MYVAR + 'DEF'
But Myvar nver changes from the Initial value
Nice trick!=)))
try
DECLARE @MYVAR varChar(1000) = 'INITIAL'
When you declare variable like char(n) and set it, the first M symbols will be set ('INITIAL'-7 chars in your case), other 1000-7=993 symbols will be ' '.
After that when you selecting variable in SSMS - it won't show you all the 1000 symbols, instead it will show you the several first one, and it will seem like 'INITIAL '.