SQL Server Business Intelligence

SQL SERVER 2005 & 2008 IS THE MAIN THEME OF THIS BLOG

Wednesday, December 28, 2005

Random data

I had a request from a client to use random products (for example 100 products per customer) when I create a dummy set of data for testing purpose. I didn't realise that there is a simple way to get random set of products being returned at each time, until I Googled it.

SELECT TOP 100 ProductId
FROM Dim_Products
ORDER BY NEWID()

NEWID() returns a UniqueIdentifier every time it runs and therefore it will return different product list each time.

Very useful when you create random data.

I am sure most people knew this, but I learnt this yesterday. So I thought I would post it as it would be useful for me in the future.

Thanks
Sutha

0 Comments:

Post a Comment

<< Home