Generate 8 Digit Random Alpha Numeric Password in MS-SQL

First create a view like this:


  CREATE VIEW GetPassword
   AS
     SELECT LOWER(LEFT(NEWID(),8)) as GenPassword
Execute this above view in database

Then create a function like this:

    CREATE FUNCTION Dbo.GeneratePassword()
     RETURNS NVARCHAR(10)
     AS
       BEGIN
            DECLARE @Password NVARCHAR(10)
                SET @Password=(SELECT GenPassword from GetPassword)
             
                 RETURN(@Password)
       END
Execute this above funtion in database

Calling Function:

    SELECT dbo.GeneratePassword() as Password

Comments

Popular posts from this blog

GROUP BY, CUBE, ROLLUP and SQL SERVER 2005

How to get content of Ckeditor & Fckeditor using Javascript

How to Fix Error- Sys.WebForms.PageRequestManagerTimeoutException - The server request timed out