Thank this author by sharing:
By Megan Beebe,
Paste the above script into a query window and see the results. The first time I saw this, I expected to see only the last row's data in the variables.
The best use I've found for this behavior is select the values out of syscolumns into a single string that I can easily paste into a select statement.
As a member of SQLServerCentral, you get free access to loads of fresh content: thousands
of articles and SQL scripts, a library of free eBooks, a weekly database news roundup,
a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals
that makes it such a success.