Penguen
Penguen

Reputation: 17298

How to solve 'invalid object name' in SQL Server?

This is the error message returned:

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

It 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',
'',
'',
'',
'',
'',
'',
'' )

Upvotes: 10

Views: 133567

Answers (6)

Tromesh 6143
Tromesh 6143

Reputation: 21

Currently learning SQL server machine learning service and I had the same issue where database table pulls from one level below but the FROM where the location was different than finding a current location.

So I wrote exactly FROM where data was coming:

FROM [WideWorldImporters].[Application].[Cities_Archive]

Hope this could help at initial level

Upvotes: 1

Sabareeshwari Kannan
Sabareeshwari Kannan

Reputation: 75

I too faced this error in plain text query.. In my web application, i have used three connection string.. i had specified that query with particular DB Name and Table name.. My error get solved.. Hope it may useful for someone..

Upvotes: 1

SEFL
SEFL

Reputation: 569

It doesn't necessarily mean that it can't find "ENG_PREP" in your SQL insert query itself. Check any triggers that run on that table as well and make sure all of them have the exact table name spelled correctly.

This JUST happened to me when debugging a stored procedure and it took me half an hour to find it.

Upvotes: 8

Hans Olsson
Hans Olsson

Reputation: 55049

Sounds like it can't find the table.

Check that you're connected to the correct database.
That the table exists and that it's the correct spelling.

Upvotes: 4

Ralf de Kleine
Ralf de Kleine

Reputation: 11756

I means the table ENG_PREP doesn't exist in the connection you are using.

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

Upvotes: 4

dcp
dcp

Reputation: 55468

It means that it doesn't know what ENG_PREP is.

You need to use a 'use xxx' (where xxx is the database name where the ENG_PREP lives) command first to tell it what database you are using. And once you do that, you need to make sure that ENG_PREP is present in that database.

If you're using .Net to connect, you need to make sure you specify the initial catalog so it knows what database to use, here's an example excerpt from a web.config:

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

Upvotes: 11

Related Questions