1: CREATE VIEW GetPassword
2: AS
3: SELECT LOWER(LEFT(NEWID(),8)) as GenPassword
Then create a function like this:
1: CREATE FUNCTION Dbo.GeneratePassword()
2: RETURNS NVARCHAR(10)
3: AS
4: BEGIN
5: DECLARE @Password NVARCHAR(10)
6: SET @Password=(SELECT GenPassword from GetPassword)
7:
8: RETURN(@Password)
9: END
Calling Function:
1: SELECT dbo.GeneratePassword() as Password
Download
Download Script
No comments:
Post a Comment