views:

65

answers:

1

I have a console app that's geared to be automatically ran as a Scheduled Task. I use LINQ to SQL to pull some data out of the database, format it into a CSV and email it to a client. All of a sudden I am getting the error "SELECT permission denied for table", but the account I'm using to connect to the database (specified in my app.config file) has the "sysadmin" server role (bad programmer, I know; I'll get around to changing it to a better account later but I want to make sure it works first).

I can connect directly to the SQL database using that very same account and query the table in question without a problem, it only seems to be when using the LINQ code. Any idea what would be causing this?

A: 

Same server and database?

The error should actually say something like "does not exist or do not have permission". Now, if you're sysadmin then permission is irrelevant so table must not exist where you think it is

Ideas:

  • Wrong server
  • Client SQL alias pointing to wrong server
  • Wrong DB context
  • Wrong schema (eg SELECT * FROM bob.myTable should be SELECT * FROM fred.Mytable)

Try SELECT @@SERVERNAME, DB_NAME() (or Linq equivalent) to see where you are as a first step...

gbn