Generating random strings with T-SQL

前端 未结 27 1876
青春惊慌失措
青春惊慌失措 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 18:40

    I realize that this is an old question with many fine answers. However when I found this I also found a more recent article on TechNet by Saeid Hasani

    T-SQL: How to Generate Random Passwords

    While the solution focuses on passwords it applies to the general case. Saeid works through various considerations to arrive at a solution. It is very instructive.

    A script containing all the code blocks form the article is separately available via the TechNet Gallery, but I would definitely start at the article.

提交回复
热议问题