How do I return random numbers as a column in SQL Server 2005?

后端 未结 12 780
误落风尘
误落风尘 2020-12-03 01:34

I\'m running a SQL query on SQL Server 2005, and in addition to 2 columns being queried from the database, I\'d also like to return 1 column of random numbers along with the

12条回答
  •  一向
    一向 (楼主)
    2020-12-03 02:00

    You might like to consider generating a UUID instead of a random number using the newid function. These are guaranteed to be unique each time generated whereas there is a significant chance that some duplication will occur with a straightforward random number (and depending on what you're using it for could give you a phenominally hard to debug error at a later point)

提交回复
热议问题