Need T-SQL to GRANT SYSAdmin Role to Windows LOGIN

  • I realize I can adjust the properties of a SQL 2005 Windows Login and assign to the SysAdmin role.

    I am in search of T-SQL to allow MyDomain\MyUser login to have SysAdmin on the SQL Server 2005 instance.  

    BT
  • Try this

    USE <dbname>;GRANT CONTROL SERVER TO <username];GO
     
    Read here:
    ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/7e880a5a-3bdc-491f-a167-7a9ed338be7f.htm
     I understand now. This will not give you what want. 
  •  EXEC master..sp_addsrvrolemember @loginame = N'Domain\Username', @rolename = N'sysadmin'

    Note that you can find things like this by using the script button that is at the top of many windows such as the Login Properties window.

     

    Bill

     

     

     

  • use master

    go

    sp_addlogin [domain\username]

    sp_addsrvrolemember [domain\username],'sysadmin'

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • Sugesh Kumar (6/26/2007)


    use master

    go

    sp_addlogin [domain\username]

    sp_addsrvrolemember [domain\username],'sysadmin'

    sp_addlogin is for SQL Authentication. You must use sp_grantlogin instead.

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

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