Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error:Invalid object name 'dbo.Admin'.

Author  Topic 

sh26
Starting Member

5 Posts

Posted - 2007-09-12 : 19:36:50
Hi,
I created the table "Admin" in my database, when I try to select * from admin , or insert into... it gives me the error:
Invalid object name 'dbo.Admin'.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-09-12 : 19:39:38
Are you in the correct database? Are you sure that the object is owned by dbo?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sh26
Starting Member

5 Posts

Posted - 2007-09-12 : 19:45:08
well, I created the database, then created a table name "Admin" and it must be mine. this is the only dtabase on the system. how could I find out, if it isn't?
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2007-09-12 : 19:46:16
what do you get when you run this in your database?

select * from information_schema.tables
where table_schema <> 'dbo'

select current_user, system_user


PS: If anyone is interested in a SQL Job in Connecticut with excellent pay please send me your resume to ValterBorges@msn.com.

Go to Top of Page

sh26
Starting Member

5 Posts

Posted - 2007-09-12 : 19:53:34
first one is empty. second one shows one row that says:
dbo myname\owner
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-09-12 : 19:55:48
If the first select doesn't return any rows, then you probably either put the object in the wrong database or are running your select from the wrong database.

Are you doing this in Query Analyzer, Enterprise Manager, or Management Studio?

Have you checked the list of tables in Enterprise Manager or Management Studio to make sure it is in your database? What owner does it show in that GUI screen?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sh26
Starting Member

5 Posts

Posted - 2007-09-12 : 20:00:46
I am doing it in studio. it's local server only.
and I see my name as owner, under that the name of database and under that the name of table.
I don't know how could it have gone to a wrong database!!!
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2007-09-12 : 20:05:34
Run this if you don't get a row for Admin then the table is not in the current database.

select * from information_schema.tables where table_name = 'Admin'

Try these also just in case you put the table in one of the system databases.

use master
select * from information_schema.tables where table_name = 'Admin'

use msdb
select * from information_schema.tables where table_name = 'Admin'

use model
select * from information_schema.tables where table_name = 'Admin'



Go to Top of Page

sh26
Starting Member

5 Posts

Posted - 2007-09-12 : 20:05:43
I got it! at the top, it was looking at "master" as default. I changed it to mine and it got ok.
thanks for guiding me through it.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-09-12 : 20:05:55
Just for your information, there are 4 ways to query an object:

1-part naming convention - SELECT * FROM ObjectName

2-part naming convention - SELECT * FROM ObjectOwner.ObjectName

3-part naming convention - SELECT * FROM DatabaseName.ObjectOwner.ObjectName

4-part naming convention - SELECT * FROM ServerNameOrLinkedServerName.DatabaseName.ObjectOwner.ObjectName

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -