Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Generating a unique username for a table of member

Author  Topic 

richardlaw
Yak Posting Veteran

68 Posts

Posted - 2012-06-04 : 10:43:35
Hi

I have a table of members (about 100) and need to create a SP that searches for all members without a username, and where it's NULL, automatically generates and adds a random 8 character username using only upper case letters and numbers.

Any ideas?

Thanks as always

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-04 : 12:40:08
see

http://blog.sqlauthority.com/2007/04/29/sql-server-random-number-generator-script-sql-query/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-06-04 : 12:48:52
Here is a quick and dirty solution. You might still get duplicates:
SELECT LEFT(REPLACE((CAST(NEWID() AS VARCHAR(36))), '-', ''), 8)
Go to Top of Page
   

- Advertisement -