[thelist] preventing duplicate randomly generated ID's was: SQL 2000 auto create ID's
rudy
r937 at interlog.com
Tue Aug 27 20:54:01 CDT 2002
> NewID() is a SQL Server function that returns a 32 byte GUID.
speaking of NEWID(), i just heard of this the other day, but in a most
interesting context
i haven't tested this myself, but apparently it works quite nicely --
<tip type="sql">
how do i select 10 random rows from my sql/server table?
SELECT TOP 10 *
FROM Northwind..Orders
ORDER BY NEWID()
http://www.microsoft.com/sql/techinfo/tips/development/queryresults.asp
</tip>
not sure if this is something you want to do all the time, particularly
since it appears to sort the entire table first, but for a one-shot deal,
it's the cat's pajamas
GUIDs are also quite useful when merging or copying tables with identity
columns
rudy
http://rudy.ca/
More information about the thelist
mailing list