Script to add login with admin right!!!

  • I want to create domain logins for almost 10 users but i want to use script for this task. All users should get admins rights on all the databases. Could anyone please provide me this script.

    Thanks a ton in advance.

    Nitin

  • Creating a new DBA group? The domain logins must be created before you can add them to SQL Server. You can use CREATE LOGIN and sp_addsrvrolemember to give the login access to SQL Server and make it a member of sysadmin.

    Something like this:

    create login DOMAIN\NEWLOGIN from windows

    go

    sp_addsrvrolemember 'DOMAIN\NEWLOGIN', 'sysadmin'

    Greg

  • Thanks so much for your suggestion,

    But what i want to achieve is we already have a domain id's and i want to add them to SQL logins using script so i am looking for the script.

    Domain is R2 and username like 501253666.

  • Just substitute R2\501253666 for DOMAIN\NEWLOGIN. Repeat the two statements for each login and run the script in a query window in SSMS

    Greg

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply