| 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 KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
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? |
 |
|
|
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_userPS: If anyone is interested in a SQL Job in Connecticut with excellent pay please send me your resume to ValterBorges@msn.com. |
 |
|
|
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 |
 |
|
|
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 KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
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!!! |
 |
|
|
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 masterselect * from information_schema.tables where table_name = 'Admin'use msdbselect * from information_schema.tables where table_name = 'Admin'use modelselect * from information_schema.tables where table_name = 'Admin' |
 |
|
|
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. |
 |
|
|
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 ObjectName2-part naming convention - SELECT * FROM ObjectOwner.ObjectName3-part naming convention - SELECT * FROM DatabaseName.ObjectOwner.ObjectName4-part naming convention - SELECT * FROM ServerNameOrLinkedServerName.DatabaseName.ObjectOwner.ObjectNameTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
|