Randomly Sort Sql server Table

You can sort a Table Randomly with a single keyword.

the newsid() is the keyword which generates a random number in sql server.

Here is small ex.

1)Create a database
2)Create Table Master
3)Create Fields Code nvarchar(50), Name Nvarchar(50)
4)Enter some data into table
5)Now open new query window
6)Write sql
7)Select * from Master Order by newid()

Now, run this code it will return data in random format.

You can also use newid() to generate a unique number or a number like verification code etc.

for ex.

Select newid()

Comments

Popular posts from this blog

How to add Primary Key and Auto Increment on different fields of MySql

Sql azure select from another database / Cross Database connection

URL rewriting and SEO