Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server invalid object name 1

Status
Not open for further replies.

iren

Technical User
Mar 8, 2005
106
US
Hi everyone!

I have a problem working with my table uploaded to SQL Server DW.
When I launch the SQLSERVER 2005 session, on the very top of the object Explorer I can see the line comrep01(SQL Server ****-COMDOMAIN\irenl) where comrep01 is the server name (Server type is Database Engine)

The very First Directory is Databases under which there are a number of subdirectories.

My concern is COMUserReporting which contains users tables among which I see my own recently uploaded table named "testNewTable" which I uploaded from my local PC( it looks like "COMDOMAIN\irenl.testNewTable")

I am trying to submit the following query based on my uploaded table:

select
ID
,NameFirst
,NameLast

FROM [COMDOMAIN.irenl].testNewTable


....However I receive the following error message:

Msg 208, Level 16, State 1, Line 1
Invalid object name 'COMDOMAIN.irenl.testNewTable'.

What I am doing wrong? Could you, please, help me with the syntax of the object name?

Thank you in advance,

Iren
 
Mostly guessing here...

It looks like your table was created under the schema [COMDOMAIN\irenl]. I'm guessing that this is probably not what you wanted.

You see... in SQL Server, you can have multiple tables with the same name in the same database. Most of the time, this is a bad idea and not at all what people actually want.

Most of the time, tables are owned by the dbo schema. dbo is a built-in database role, and is an acronym for Data Base Owner. If you want to change your table so that it is owned by dbo, then you can run this:

[tt]sp_changeobjectowner [COMDOMAIN\irenl].testNewTable, dbo.testNewTable[/tt]

Then you can change your code to:



Code:
Select
ID
,NameFirst
,NameLast

  FROM testNewTable

If you don't want to change the schema, then...

Code:
select
ID
,NameFirst
,NameLast

  FROM [COMDOMAIN[!]\[/!]irenl].testNewTable

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top