title: How can i create role on random name
body: <p>i want to create role on Moderator. Moderator is first 3 user's. Moderator role is update, delete, insert. how to decide it ? </p>
  
  <pre><code>create table TmpUsers(
      ID  int identity (1,1) primary key not null,
      UserID nvarchar(10) not null,
      Pass nvarchar(20) not null,
      LastLogin datetime not null,
      LastLogOut datetime not null
  )
  DECLARE @sql NVARCHAR(4000),
          @username nvarchar(6),
          @password nvarchar(6),
          @random int,
          @count int
  set @count=1;
  While(@count&lt;10) 
  begin 
  SET NOCOUNT ON
     set @username = 'User'+CONVERT(nvarchar,@count)
     set @random = (select RAND()*98+1)
     set @password = 'User'+CONVERT(nvarchar,@count)
      SET @SQL = 'CREATE LOGIN ' + @username + ' WITH PASSWORD = '+''+@password+''+', DEFAULT_DATABASE=[Patient]';
     EXECUTE(@SQL)
               set @count=@count+1;
               Insert into TmpUsers([UserID],[Pass])
               values(@username,@password)
               create role UserID
               grant select on OnlineGutal to NS
               where (select ID from TmpUsers = 1) 
               EXEC sp_addrolemember 'UserID', 'NS';
  end
  </code></pre>