title: BCP in SQL command give NativeError = 2 when no -S parameter on local DB
body: <p>I have this command in SQL:</p>
  
  <pre><code>DECLARE @cmd NVARCHAR(4000)
  DECLARE @pathAndFileName NVARCHAR(MAX)
  DECLARE @result INT
  SET @pathAndFileName = 'C:\Temp\file.csv'
  SET @cmd = 'bcp "SELECT TOP 1 * FROM SomeDB.dbo.SomeTable" queryout "'
    + @pathAndFileName + '" -w -T -t; '       
  EXEC @result = xp_cmdshell @cmd 
  SELECT @result
  </code></pre>
  
  <p>and it outputs this:</p>
  
  <pre><code>SQLState = 08001, NativeError = 2 Error = [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [2]. 
  SQLState = 08001, NativeError = 2 Error = [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. 
  SQLState = S1T00, NativeError = 0 Error = [Microsoft][SQL Server Native Client 11.0]Login timeout expired
  </code></pre>
  
  <p><code>@result</code> is 1</p>
  
  <p>It works only if I add -S parameter with server name and database name (like this <code>-S "MYCOMPUTERNAME\DBINSTANCENAME"</code>).</p>
  
  <p>But when I try this on remote server this works without <code>-S</code> parameter.</p>
  
  <p>How can I setup my local DB, so I don't need <code>-S</code> anymore?</p>