This article is half-done without your Comment! *** Please share your thoughts via Comment ***
Most of you guys are already using NEWID() for forming a random number in SQL Server.
Freshly, I got a new SQL Puzzle which is small and sweet.
As an interviewer, I can ask one line question like “Can you please generate random number column which should be between 0 and 50”
Very reasonable and small question right, believe me, the answer is also in one line.
Check the below solution, and try it your self.
Solution:
1 |
SELECT ABS(CHECKSUM(NewId())) % 50 AS RandomNumber |
Please try the different solution for this puzzle and share it via comment...