title: SQL - BCP out problems with login credentials
body: <p>So I've been surfing through some of the questions related to my issue but I still can't seem to solve it. I had this working on my own SQL server but as soon as I moved it to a different server I now have an issue.</p>
  
  <p>Here is the bcp out command I am using:</p>
  
  <pre><code>declare @sql varchar(1000)
  set @sql = 'bcp DatabaseName.dbo.TableName out C:\'+@name+'.txt -c -t"\t" -T -U"'+@user+'" -P"'+@password+'" -S"'+ @@SERVERNAME +'"'
  
  exec master..xp_cmdshell @sql
  </code></pre>
  
  <p>But I am getting this in return from the server:</p>
  
  <pre><code>SQLState = 37000, NativeError = 4060
  Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database "DatabaseName" requested by the login. The login failed.
  SQLState = 28000, NativeError = 18456
  Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'NT AUTHORITY\SYSTEM'.
  NULL
  </code></pre>
  
  <p>I have no idea what I'm doing wrong right now and I've tried doing the fixes I've seen in other threads about it but still nothing.</p>
  
  <p><strong>Edit:</strong> I previously used this command on my own server and it worked just fine.</p>
  
  <pre><code>declare @sql varchar(1000)
  set @sql = 'bcp DatabaseName.dbo.TableName out C:\'+@name+'.txt -c -t"\t" -T -S'+ @@SERVERNAME
  </code></pre>
  
  <p>I also removed the -T in my first command and it had a login failed for the user instead of the NT Authority system account. Even though the login is correct.</p>
  
  <p>Solved... I'm stupid. </p>