I'm running a simple select statement.
Select TestSchema From TestDB where DbName = 'TEST'
It runs fine when I run it in Enterprise Manager.
But I get an error message when I run it in Query Analyser.
Error: Invalid object name 'TestDB'
Help!DBNAME is a built-in function. If your table has a column of that name,
try:
Select TestSchema From TestDB where [DbName] = 'TEST'
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com
"sql" <sql@.discussions.microsoft.com> wrote in message
news:DC485C69-107A-4A63-8B1B-6B71BCBA75AE@.microsoft.com...
I'm running a simple select statement.
Select TestSchema From TestDB where DbName = 'TEST'
It runs fine when I run it in Enterprise Manager.
But I get an error message when I run it in Query Analyser.
Error: Invalid object name 'TestDB'
Help!|||Tom:
I tried with the square brackets, but I still get the same error message.
"Tom Moreau" wrote:
> DBNAME is a built-in function. If your table has a column of that name,
> try:
> Select TestSchema From TestDB where [DbName] = 'TEST'
>
> --
> Tom
> ---
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinnaclepublishing.com
>
> "sql" <sql@.discussions.microsoft.com> wrote in message
> news:DC485C69-107A-4A63-8B1B-6B71BCBA75AE@.microsoft.com...
> I'm running a simple select statement.
> Select TestSchema From TestDB where DbName = 'TEST'
> It runs fine when I run it in Enterprise Manager.
> But I get an error message when I run it in Query Analyser.
>
> Error: Invalid object name 'TestDB'
> Help!
>|||Tom,
Isn't the function db_name()?
I'm suspicious that the table may be under a different owner name. Try owner qualify the table to see what you get.
Richard
--
Message posted via http://www.sqlmonster.com|||Oops, you're right. I'd be tempted to run the profiler and see what's being
sent when he runs it (successfully) through Enterprise Manager. That may
give a clue.
--
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com
"Richard Ding via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:d534a166a789418e873d7ab25b41a525@.SQLMonster.com...
Tom,
Isn't the function db_name()?
I'm suspicious that the table may be under a different owner name. Try owner
qualify the table to see what you get.
Richard
--
Message posted via http://www.sqlmonster.com
No comments:
Post a Comment