Generating random strings with T-SQL

前端 未结 27 1860
青春惊慌失措
青春惊慌失措 2020-11-29 18:10

If you wanted to generate a pseudorandom alphanumeric string using T-SQL, how would you do it? How would you exclude characters like dollar signs, dashes, and slashes from

27条回答
  •  既然无缘
    2020-11-29 19:00

    I'm not expert in T-SQL, but the simpliest way I've already used it's like that:

    select char((rand()*25 + 65))+char((rand()*25 + 65))
    

    This generates two char (A-Z, in ascii 65-90).

提交回复
热议问题