The SQL Server is just tried your query on is as follows:
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 2)
Here's another way around, as using a CTE instead of a temp table failed to produce the desired results in the same way the original query does, which is really interesting when you think about it.
DECLARE @X NVARCHAR(MAX)
SET @X = ''
SELECT [name], NEWID() AS NEW_ID
INTO #TEST
FROM msdb.sys.tables
SELECT @X = @X + 'PRINT ''[' + [name] + ']'';' + CHAR(13) + CHAR(10)
FROM #TEST
ORDER BY NEW_ID
--PRINT @X
EXEC (@X)
GO
DROP TABLE #TEST
Steve
(aka smunson)
:):):)
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)