SQL Server: RequestError: Invalid object name 'Table Name'.

Crystal YU 31 Reputation points Microsoft Employee
2021-05-11T02:38:30.937+00:00

I create an database in the azure. And try to access the table in app service. When I start the app service in local machine, and it works fine. but When I deploy the app service in azure, the app service will fail to access the table, the error is 'RequestError: Invalid object name '[table Name]'.'

What's the problem and how can I fix the issue?

Thanks,

Azure SQL Database
0 comments No comments
{count} votes

Accepted answer
  1. Oury Ba-MSFT 20,911 Reputation points Microsoft Employee Moderator
    2021-05-26T22:40:40.043+00:00

    Hello @Crystal YU In addition to what Morillo mentioned above on the root cause of the issue.

    1. Are you getting this error on only one table or for all tables , if you are seeing this on only one table then you simply made a mistake in naming when creating the table.
    2. If it is for all tables , then you may need to verify if schema name is the same on Azure
    3. List item

    Please let us know

    Regards,
    Oury


2 additional answers

Sort by: Most helpful
  1. Alberto Morillo 34,671 Reputation points MVP Volunteer Moderator
    2021-05-11T04:14:00.733+00:00

    In your code, you may be connecting directly to the master database. Do not forget to specify the database name you are connecting once you get connected to the logical SQL Azure server (server1.database.windows.net). Make sure the database name on Azure match the database name you use on your local SQL instance.

    Update your app service with the correct database name, table name, and logical Azure SQL server name, as they may not be the same as your local environment.

    Make sure the table exist on the same schema.


  2. Crystal YU 31 Reputation points Microsoft Employee
    2021-05-11T04:17:36.537+00:00

    I specified the database name in the connection config(see following) when I try to connect it. And the app service deployed in Azure is the same code with the one deployed local.
    var config = {
    user: user,
    password: password,
    server: server,
    database: database,
    };


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.