Question :
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 \IPAddressd$LogStudentLog_'+@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?
Answer :
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: IPAddressd$ /user:<domainlogin> /savecred