Saturday, January 21, 2006

Use Globally Unique Identifiers in Access and SQL Server: "You can also use GUID values to randomly select rows from a table or view, and you don't have to create a uniqueidentifier column to take advantage of this technique. You can use the NEWID() function to generate GUID values in a query. To illustrate this unique use, execute the following query in SQL Server Desktop or SQL Server:


SELECT TOP 10 dbo.Products.ProductID, dbo.Products.ProductName,
dbo.Products.UnitPrice
FROM dbo.Products
ORDER BY NEWID()

The resultset contains 10 seemingly random product records (see Figure 2). This technique is beneficial when featuring random products on a Web site or selecting random records for an audit."

0 Comments:

Post a Comment

<< Home