Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Brand new error - Invalid object name in T-SQL insert statement Expand / Collapse
Author
Message
Posted Wednesday, February 5, 2014 2:09 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 7, 2014 10:14 AM
Points: 6, Visits: 7
I've been using SQL Server 2008 R2 for my web development for years and it's been working perfectly. But something strange happened last night that has stopped my development in my tracks.

Here's some steps in the process:

-- I create a new database from the Management Studio, named "BloggerTest" (dbo)
-- I open a query window and paste in a CREATE table sql script for many tables, such as [dbo].[Blog], etc., with the "use [BloggerTest] GO" at the top
-- I run the script and it runs without errors or messages, and I validate that the tables were created
-- I open another query window and paste in another script for INSERT statements into some of the tables
-- Before I run the script I notice that all the INSERT statement objects display the red squigglie lines under them. When I hover my cursor over the table name I get the message, "Invalid object name '[dbo].[Blog]'". The same squiggle is under all the column names also.

Now here's the part that makes my head explode. I have another table with the same tables and it's a working application, the database is named "BlogApp".

When I change the name of the "use" value from [BloggerTest] to [BlogApp] at the top of the INSERT sql script T-SQL query, all the red squigglie lines disappear!

What the heck is going on? The script that is creating the tables for BloggerTest is the same script that created the tables for BlogApp, so why is this a problem? I've also created the database the exact same way.

And to clarify some things so you don't have to ask questions about it:

-- this is my local development laptop
-- no one else is using this machine
-- the tables exist, in both databases

I've looked through these Forum posts for answers and have not found one. I've also scoured stackoverflow and other resources and haven't found and answer there either. Does anyone have an understanding of why this occurs, because at the moment, it's preventing me from creating new databases.

Any help is appreciated. Thanks.
Post #1538373
Posted Wednesday, February 5, 2014 2:22 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 8:12 AM
Points: 13,326, Visits: 12,814
That is because your intellisense needs to be refreshed. ctrl+shift+r

Wait a couple seconds and the "red squigglies" will go away.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1538379
Posted Wednesday, February 5, 2014 6:40 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 7, 2014 10:14 AM
Points: 6, Visits: 7
Sean, thanks for the response, but that wasn't it.

I'll keep working on it.
Post #1538442
Posted Wednesday, February 5, 2014 7:11 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 10:25 AM
Points: 18,060, Visits: 16,095
This will usually resolve for me if I shut down SSMS and re-open it.

At any rate, the red squiggles are just for intellisense and the queries should continue to work for you.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1538444
Posted Thursday, February 6, 2014 7:42 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 8:12 AM
Points: 13,326, Visits: 12,814
Did you execute a USE statement in SSMS? I have seen many times where that seems to totally confuse intellisense. If however, you use the combobox at the top it seems to keep intellisense in line.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1538655
Posted Friday, February 7, 2014 10:17 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 7, 2014 10:14 AM
Points: 6, Visits: 7
Sean Lange (2/6/2014)
Did you execute a USE statement in SSMS? I have seen many times where that seems to totally confuse intellisense. If however, you use the combobox at the top it seems to keep intellisense in line.


I used both and everything and initially the red squiggles persisted, but as mentioned by another poster it did not interfere with it executing.

But for some reason today when I opened SSMS and pasted in my Insert statements into a query window, the red squiggles were gone! I don't think I did anything different, but I like it anyway.

Thanks to everyone who helped out with this.
Post #1539281
Posted Friday, February 7, 2014 10:22 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 8:58 AM
Points: 4,043, Visits: 9,198
Sometimes Intellisense won't work great and can become a PITA.
I sure like it, but it can get some improvements and bug fixing.



Luis C.
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1539284
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse