Just for fun, i have to get all values from a table, into an 'array' like, all values separated with commas.
Some guys told me to use a cursor or an while ... loop.
The mission is only a concatenate, why i have loop it?
What you have to do is:
First you have to declare a string.
Then you can concatenate all the rows into the string,
and finnaly you have to cut the tips.
SELECT is like a loop that you can do some stuff on each row.
Some one told that if you do SELECT @i=id FROM XPTO
you will get the last id, that is almost wrong. You get the last because you are setting, on each row, a new vaue to @i.
But if we always keep the value of @i we can get all the records in a row.
Have fun TSQLing.