Gary Harding (4/27/2015)
Jeff Moden (4/26/2015)
You're seriously aware of one of the more famous Pseudo-Cursors there is... a SELECT that uses a Tally Table.When I first saw this type of usage I thought it was black magic...
DECLARE @Nums varchar(8000) = ''
;WITH T(n) AS (SELECT TOP(100) ROW_NUMBER() OVER (ORDER BY @@SPID) FROM sys.all_columns)
SELECT @Nums += CAST(n AS varchar) + ','
FROM T
PRINT @Nums
'Zactly. "Set Based Loop/Pseudo Cursor" tried and true.
--Jeff Moden
Change is inevitable... Change for the better is not.