Showing posts with label googlerepository. Show all posts
Showing posts with label googlerepository. Show all posts

Monday, March 19, 2012

Bogus "Invalid object name" error

Hi all,
I'm posting this so it'll be archived in the great google
repository, and hopefully be useful to someone. I spent awhile
troubleshooting what turned out to be a completely misleading error
arising from a simple typo in a query. Here's the crux:
create table foo (id int)
The command(s) completed successfully.
insert foo ('id') values (1)
Server: Msg 208, Level 16, State 3, Line 1
Invalid object name 'foo'.
insert foo (id) values (1)
(1 row(s) affected)
drop table foo
The command(s) completed successfully.
--
My first insert statement has incorrect single quotes around the
column name, which for some reason leads to the error shown.
Unfortunately, my real-life problem was much more convoluted, and
this took a couple hours to debug. I hope this post saves someone
time someday! This is on SQLServer 2000 w/SP3a.
Cheers...It probably won't when it happens, but it may for people who read it :)
These strange types of error messages have been around as long as time
itself. Thanks for posting stuff like this!
--
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Jerry" <leavemealone@.nowhere.com> wrote in message
news:Xns9660740FD7089leavemealonenowhere
c@.207.225.159.8...
> Hi all,
> I'm posting this so it'll be archived in the great google
> repository, and hopefully be useful to someone. I spent awhile
> troubleshooting what turned out to be a completely misleading error
> arising from a simple typo in a query. Here's the crux:
> --
> create table foo (id int)
> The command(s) completed successfully.
> insert foo ('id') values (1)
> Server: Msg 208, Level 16, State 3, Line 1
> Invalid object name 'foo'.
> insert foo (id) values (1)
> (1 row(s) affected)
> drop table foo
> The command(s) completed successfully.
> --
> My first insert statement has incorrect single quotes around the
> column name, which for some reason leads to the error shown.
> Unfortunately, my real-life problem was much more convoluted, and
> this took a couple hours to debug. I hope this post saves someone
> time someday! This is on SQLServer 2000 w/SP3a.
> Cheers...