Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between New_Id() & Rand() SQLSERVER2005

How newid() Function Work in Back Ground ?

What is the difference between rand() and newid() ?

Which is more efficient?

Thanks in advance.

like image 720
priyanka.sarkar Avatar asked Sep 15 '25 23:09

priyanka.sarkar


1 Answers

The problem with rand is that it returns the same value for all the rows for a call. newid will be different for every row. This article explains things clearly

https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-6089823.html#

like image 120
Stuart Avatar answered Sep 17 '25 18:09

Stuart