Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Any ideas ??


Message #1 by "CMY" <my62202@y...> on Tue, 26 Nov 2002 06:42:57
wah..this method is great....
thanks a lot for the help....

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "CMY" <my62202@y...>
Subject: [aspx_professional] Re: Any ideas ??


: Is it every records in product table is assigned a unique value by using
: newid() ?
:
: And therefore when i use 'select top 100 * from product order by newid
()',
: it will select the first 100 records according to the order of the value
: assigned by newid() ?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

That is correct. To see it in action, try doing the following:

-- Replace field1, field2, mytable with your fields/table!!
SELECT
    Field1,
    Field2,
    NewID()
FROM
    myTable
ORDER BY
    3

Run this a few time in Query Analyser, and you will see that NewID()
generates a new UniqueIdentifier for each row, each time you run the 
query.

Cheers
Ken


  Return to Index