Search This Blog

2009-10-01

Generate random numbers in T-sql

SELECT CAST(CAST(NEWID() AS BINARY(15)) AS INT)
or
SELECT SUBSTRING(CAST(CAST(CAST(NEWID() AS BINARY(15)) AS INT)AS VARCHAR),2,7)

No comments: