Monday, March 12, 2012

Permissions for BULK INSERT?

I'm trying to do a BULK INSERT into a SQL Server 2005 db from an aspx page. When I try to run the page, to insert into [myTable], I get:
The current user is not the database or object owner of table 'myTable'. Cannot perform SET operation.
But here's the kicker: if I use Server Management Studio to log into the same database, using the same credentials, and run the same query, it works fine.

My connection string looks like this:

connectionString="data source=myLocalMachine; initial catalog=myCatalog; user=joe; password=joe;" providerName="System.Data.SqlClient"
Can anybody tell me why it works when I log in via SMS, but not when I try the same query from my aspx? I'm totally stuck.

Thanks!I am no SQL Server 2005 expert, but as far as I am aware, running BULK INSERT from Server Management Studio will be using different user credentials than running the process from your ASP.NET page. As far as I understand it, user joe needs to have BulkAdminprivileges. Or, you need to termporarily impersonate an account whichhas those privileges.

Reading the documentation onBULK INSERT may help, as well asPermissions of Fixed Server Roles.

No comments:

Post a Comment