[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. 

-Paul 




-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur
Fuller
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.

A.
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com


__________ NOD32 2968 (20080324) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com





More information about the dba-SQLServer mailing list