How to resolve an "invalid object name" in SQL Server?

This error message is:

Msg 208, Level 16, State 1, Line 1 Invalid object name "ENG_PREP".

This happens after I try the following query:

insert into ENG_PREP VALUES('572012-01-1,572012-01-2,572012-01-3,572013-01-1,572013-01-2', '', '500', '', 'A320 P.001-A', 'Removal of the LH Wing Safety Rope', '', '', '', '0', '', 'AF', '12-00-00-081-001', '', '', '', '', '', '', '' ) 
+4
source share
5 answers

This means that he does not know what ENG_PREP .

You need to use 'use xxx' (where xxx is the name of the database in which the ENG_PREP command lives) to tell which database you are using. And as soon as you do this, you should make sure that ENG_PREP present in this database.

If you use .Net to connect, you need to make sure that you specify the start directory so that it knows which database to use, here is an excerpt from web.config :

 <add name="SqlConnection" connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=your_db_name_here;Integrated Security=True" providerName="System.Data.SqlClient" /> 
+8
source

This does not necessarily mean that it cannot find "ENG_PREP" in the SQL query itself. Check all the triggers that run on this table and make sure they all have the exact table name that is spelled correctly.

It just happened to me when debugging a stored procedure, and it took me half an hour to find it.

+4
source

I mean, in the connection you are using, ENG_PREP does not exist.

Check if you are connected to the correct server / database. Also check the table name.

+3
source

It looks like he cannot find the table.

Make sure you are connected to the correct database.
That the table exists and that it is the correct spelling.

+1
source

I also ran into this error in a text query. In my web application, I used three connection strings. I specified this query with a specific database name and table. My mistake is resolved. Hope this can be helpful for someone ..

0
source

Source: https://habr.com/ru/post/1313181/


All Articles