How to use BCP Utility queryout in a network path with crededential (login required) for SQL Server I'm having a hard time figuring out on how can I export my selected table in a network path that requires login credentials.
'bcp &quot;select ''StudentName'' UNION ALL SELECT StudentName AS StudentName from [School].[dbo].[ClassRoom]&quot; &quot;queryout \\IPAddress\d$\Log\StudentLog_'+@fileTimeStamp+'_01'+'.'+@fileExtension+'&quot; -c -t, -T -S' + @@servername 

Running this gives me an error of

SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC Driver 11 for SQL Server]Unable to open BCP host data-file
NULL

Where should i put in the script the authentication for my network path?
The BCP utility does not have option to provide credentials for network path authentication where output file will reside. One alternative is to map the network path as local drive with &quot;net use&quot; providing User/password to authenticate. Then use local drive in BCP command.
e.g.
net use e: \IPAddress\d$\  /user:&lt;domain\login&gt;  /savecred