Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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',
'',
'',
'',
'',
'',
'',
'' )
like image 859
ALEXALEXIYEV Avatar asked Jun 18 '10 12:06

ALEXALEXIYEV


People also ask

What is invalid object name in SQL Server?

This typically means 1 of 2 things... you've referenced an object (table, trigger, stored procedure,etc) that doesn't actually exist (i.e., you executed a query to update a table, and that table doesn't exist). Or, the table exists, but you didn't reference it correctly...

Why does SQL say invalid object?

This problem occurs when you connection to your SQL server using SSMS but forget to change the database to your ConfigMgr. The solution to this is simple, using the drop down menu change the database from master to you CM database. The you can re-run your query.

How do I refresh SQL Server Management Studio?

Select the Edit menu, select IntelliSense, then select Refresh Local Cache. Use the CTRL+Shift+R keyboard shortcut.

How do I save a stored procedure in SQL Server?

To save the modifications to the procedure definition, on the Query menu, select Execute. To save the updated procedure definition as a Transact-SQL script, on the File menu, select Save As. Accept the file name or replace it with a new name, and then select Save.


1 Answers

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" />
like image 68
dcp Avatar answered Oct 15 '22 01:10

dcp