From: Erland Sommarskog on
lk (gofyself(a) writes:
> Therefore I had already verified that it gave me an error (invalid object)
> before I posted.

In your original post you said that the error was "invalid syntax near .".
There are situations when you can get syntax error in one database, but
not another, when the databases has different compatibility settings. But
I could not see that your query could have this effect.

Now you present a different error message: "invalid object", which casts
the problem in an entirely different light. You are simply running the
query from the wrong database. In the toolbar in Mmgt Studio there is a
dropdown where you can select which to database to work from. You can
also change the current database with the USE command:

USE AdventureWorks

In the future, make the habit to always post error messages in verbatim.
Thereby you can avoid this kind of confusion.

Erland Sommarskog, SQL Server MVP, esquel(a)

Links for SQL Server Books Online:
SQL 2008:
SQL 2005:
SQL 2000: