Generating random strings with T-SQL

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

    Use the following code to return a short string:

    SELECT SUBSTRING(CONVERT(varchar(40), NEWID()),0,9)
    

提交回复
热议问题