title: How do I add a Windows user to the sysadmin server role in SQL Server 2012?
body: <p>I have a Powershell script that executes in the context of a Windows user. This user has a login on a SQL 2012 instance that is a member of the sysadmin server role.</p>
  
  <p>I want the script to add another login on the SQL instance (which also has a corresponding Windows user) to the sysadmin server role.</p>
  
  <p>To try this out in Management Studio (connected as SA), I'm using the following script:</p>
  
  <pre><code>execute as user = 'domain\currentsysadmin'
  
  IF IS_SRVROLEMEMBER('sysadmin', 'domain\futuresysadmin') != 1
      ALTER SERVER ROLE [sysadmin] ADD MEMBER [domain\futuresysadmin]
  
  revert
  </code></pre>
  
  <p>I have two issues here:</p>
  
  <ol>
  <li><p>When I run the script as it's displayed here, the call to IS_SRVROLEMEMBER returns 0 as expected, but even though the domain\currentsysadmin login is a member of sysadmin, the call to ALTER SERVER ROLE returns:</p>
  
  <p>Msg 15151, Level 16, State 1, Line 8
  Cannot alter the server role 'sysadmin', because it does not exist or you do not have permission.</p></li>
  <li><p>When I run this in the context of SA without the EXECUTE AS statement, the ALTER SERVER ROLE statement appears to run successfully, but when I check the domain\futuresysadmin login, it is still not a member of the sysadmin role</p></li>
  </ol>
  
  <p>How can I add the domain\futuresystem login to the sysadmin server role?</p>