Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE procedure dbo.AllAccessIDgenerator (
- @showID varchar(40)
- @accessID varchar(100) OUT )
- As
- Begin
- declare @codeLength int
- declare @characters varchar(100)
- declare @count int
- set @characters = ''
- set @codeLength = 8
- -- set A - Z (uppercase)
- set @count = 65
- while @count <=90
- begin
- set @characters = @characters + Cast(CHAR(@count) as char(1))
- set @count = @count + 1
- end
- end
- -- set 0-9
- set @count = 48
- while @count <=57
- begin
- set @characters = @characters + Cast(CHAR(@count) as char(1))
- set @count = @count + 1
- end
- end
- set @count = 0
- set @accessID = ''
- while @count <= @codeLength
- begin
- set @accessID = @accessID + SUBSTRING(@characters,CAST(ABS(CHECKSUM(NEWID()))*RAND(@count) as int)%LEN(@characters)+1,1)
- set @count = @count + 1
- end
- end
- end
- GO
Add Comment
Please, Sign In to add comment