I have this code:
declare @.var varchar(3000)
select @.var = @.var + column1 + ', '
from table1
select @.var
This statements give as a result all the values in column1 followed each by
a coma. My problem is that in a particular sever that doesn't work ok. If I
run the statements inside a proc it only returs the last value in the table,
but if I run it outside the proc (same query) it gives me the correct
results. Does anyone know why could that be?..
THanks>> Does anyone know why could that be?..
The SELECT statement you have is not a valid or supported in t-SQL. It is
simply a hack which seems to work in some cases, but breaks in a variety of
scenarios. Avoid such make-shift constructs due to its undocumented & risky
nature.
Anith
Friday, February 10, 2012
Concatenating strings in a Select statment
Labels:
codedeclare,
column1,
concatenating,
database,
microsoft,
mysql,
oracle,
select,
server,
sql,
statements,
statment,
strings,
table1select,
var,
varchar,
varthis
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment