如何在SQL中生成随机数?

时间:2018-08-07 12:12:27

标签: sql-server command

如何在sql命令中生成唯一和随机数(5个字符)?

样本数据:

Column K_ID and many row 
ID1:63487 
ID2:21583

2 个答案:

答案 0 :(得分:2)

使用NEWID()

select  10000 + abs(convert(bigint, convert(varbinary(20), newid()))) % 90000

答案 1 :(得分:0)

{
    "version": "0.2.0",
    "compounds": [
        {
            "name": "Launch & Debug",
            "configurations": [ "Launch Program", "Launch localhost" ]
        }
],
"configurations": [
    {
        "type": "php",
        "request": "launch",
        "name": "Launch Program",
        "cwd": "${workspaceRoot}",
        "port": 9000
    },
    {
        "name": "Launch localhost",
            "type": "edge",
            "request": "launch",
            "url": "http://localhost/public",
            "webRoot": "${workspaceRoot}"
        }
    ]
}