0

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 "select ''StudentName'' UNION ALL SELECT StudentName AS StudentName from [School].[dbo].[ClassRoom]" "queryout \\IPAddress\d$\Log\StudentLog_'+@fileTimeStamp+'_01'+'.'+@fileExtension+'" -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?

1
  • Did you try -U and -P option. I guess this user(domain account) has access to sql server. Jul 11, 2020 at 11:17

1 Answer 1

1

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 "net use" providing User/password to authenticate. Then use local drive in BCP command. e.g. net use e: \IPAddress\d$\ /user:<domain\login> /savecred

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.