title: How can I use SQLCMD with Windows Authentication (-E,) but without elevated permissions
body: <p>I'm going to create a script to execute numerous SQL files. I've chose to use SQLCMD instead of ADODB because it provides logging information quickly, and we're executing T-SQL. I'm testing out SQLCMD.exe <strong>before putting it into the script</strong>.</p>
  
  <p>Connecting to the database using SQLCMD.exe, I utilize -E for Windows Authentication. This means that I need to use my network account, which does not have elevated access on any given machine. However, SQLCMD.exe requires elevated access in order to execute a query, otherwise I receive the following error:</p>
  
  <blockquote>
    <p>Sqlcmd: Error: Error occurred while opening or operating on file (Reason: Access is denied).</p>
  </blockquote>
  
  <p>After running the following command:</p>
  
  <pre>
  sqlcmd.exe -S &lt;SQLSERVER,PORT&gt; -d &lt;DATABASE&gt; -i scriptfile.sql -o scriptfile.log -E
  </pre>
  
  <p>How can I utilize SQLCMD.exe with elevated local permissions (Administrator) but use Windows Authentication to connect to the server (using a non-Administrator account)? I'd prefer not to change any permissions of SQLCMD.exe, as there may be multiple people that use this script that I'm not keen on informing them of this prior instruction.</p>