Generating random string in T-SQL

Possible Duplicate:
Generating random strings with T-SQL

I need to generate a random string with alpha and numeric characters inside a trigger.

  • Simulating group_concat MySQL function in Microsoft SQL Server 2005?
  • What is the difference between Trusted_Connection and Integrated Security in a connection string?
  • TSQL USE ROW_NUMBER IN CTE, SELECT ORDER BY NOT WORKING
  • Simple task: Connect to database, execute a stored procedure, disconnect
  • Get Hours and Minutes (HH:MM) from date
  • Dynamic table creation in SQL Server
  • The string must have a length of 15 and uppercase.

    Someone have an idea?

  • SQL Server: how to know if any row is referencing the row to delete
  • SELECT only latest record of an ID from given rows
  • DELETE EXCEPT TOP 1
  • Authenticating SQL connection using certificates in .NET
  • Using a table-value function inside a view in SQL Server
  • String Comparison differences between .NET and T-SQL?
  • 2 Solutions collect form web for “Generating random string in T-SQL”

    This is far from an optimal solution, but it will work as specified:

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

    Example output:

    WCZOVRCIRELAJUT
    

    generate a GUID and take just the first 15 characters?

    Generate a bunch of random numbers and translate to their ASCII values?

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.