Create New Login And Add It To Sysadmin Role
declare @login nvarchar(200)
declare @cmd nvarchar(4000)
 
set @login = 'MyDomain\SQLDBAGroup'
 
if not exists (select NULL from syslogins where name = @login)
BEGIN
    if @@version like '%SQL Server  2000%'
        set @cmd = 'EXEC master..sp_addlogin ' + @login
    else
        set @cmd = 'CREATE LOGIN [' + @login + '] , DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF'
 
    --select     @cmd
    exec (@cmd)
END
 
EXEC master..sp_addsrvrolemember @loginame = @login, @rolename = N'sysadmin'
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License