[dba-SQLServer] SQL to create Integer Random

Paul Nielsen pauln at sqlserverbible.com
Mon Mar 24 10:10:30 CDT 2008

2 points,

IN a transaction, I've seen SQL Server generate just one newid() and insert
the same value into every row. 

When selecting random rwos (a common usage of newid()), it's good to combine
the order by newid() with a tablesample option. 


-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur
Sent: Monday, March 24, 2008 10:54 AM
To: Discussion concerning MS SQL Server
Subject: Re: [dba-SQLServer] SQL to create Integer Random

I'm not sure why you want it inserted, but if you just want ordering there
is an easy way. Order By RowID(). You could physically insert that too if
you wanted.

dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com

__________ NOD32 2968 (20080324) Information __________

This message was checked by NOD32 antivirus system.

More information about the dba-SQLServer mailing list