Radu Gheorghiu
Radu Gheorghiu

Reputation: 20509

Export XML file from SQL Server - NT AUTHORITY\NETWORK Service error

I've been trying to export the contents of an XML variable to a file on my disk from SSMS (SQL Server Management Studio) with the following command.

EXEC xp_cmdshell 'bcp "SELECT @xml_file" queryout "C:\Radu\bcptest.txt" -T -c -t'

When running this command I'm constantly getting this error:

enter image description here

I've searched for answers and most of the things I found involved adding this NT AUTHORITY\NETWORK SERVICE user to my database as a trusted user in SSMS, which would log in using Windows authentication, but this still didn't work.

enter image description here

I have also added roles as bulkadmin and public (in case of the user in Security->Logins path), db_datareader, db_datawriter and public, access to the master database which I am using (permission to connect, login), and also the same properties and permissions for the DB_BULK_IMPORT_User, but without success.

I've also changed in IIS the Impersonation of ASP .NET to enabled and restarted IIS server and the database server after each modification.

Is there something I'm missing? Or something I'm doing too much?

Thanks in advance!

Upvotes: 1

Views: 254

Answers (1)

Mike Gardner
Mike Gardner

Reputation: 6651

-T flag specifies that you are using a trusted connection using integrated security. You may want to drop the -T and try specifying a username (-U) and password (-P).

Upvotes: 1

Related Questions