Today, we are going to talk about one of the most popular errors which user see every day. There are many users who often get stuck at this error and have no clue how to move forward with this error in SSMS. It is quite possible you may say this is a very simple error and you knew about it, well good for you. Remember this blog post is for everyone who have faced error 208 – Invalid Object Name and have no idea how to move forward from this point.
First, let us see how this error happens.
When a new user is trying to explore any database, they usually, go via the route of SQL Server Management Studio. When they try to access any object via any valid T-SQL command, often they end up with the following error.
What primarily confuses users is that they are able to see that object is clearly visible in the SSMS Object Explorer, but when they try to access that via valid T-SQL they usually face the error. I have seen DBA and Developers to often restarting SSMS, restarting machine and furiously trying to refresh their queries and database helplessly. However, the problem is very simple one and almost all of us learn it eventually.
Workaround/Solution:
This error happens primarily due to database context mismatching. When people open SSMS, they usually do not notice that their default database context is set to master in the most of the cases. We just have to change the database context to whatever database our current object is and everything will start working immediately.
This is so popular error that you will find every single DBA in the world experiencing it quite frequently. However, as the solution is so quick, we all learn how to fix it.
Another alternative would be prefix your database with a multipart database name. You can read about it over here: SQL SERVER – Explanation and Example Four Part Name
Additionally, you can also change the default database when you login in SSMS to another database than the master database. You can read about it over here: SQL SERVER – Connecting Specific Database on Starting SSMS
Reference: Pinal Dave (https://blog.sqlauthority.com)
4 Comments. Leave new
Don’t forget about the SSMS IntelliSense Local Cache as well! I’ve been burned by this quite a few times when creating new objects for instance. There are probably many other cases where the local cache used by IntelliSense becomes stale and will cause the “dreaded red squiggly”, but creating new objects is where I seem to run into this the most. Unfortunately, it’s not very obvious about how to go about refreshing it, but there are actually two pretty easy ways: 1) A simple Ctrl + Shift + R on your keyboard, or 2) Navigate Edit -> IntelliSense -> Refresh Local Cache.
Cheers,
Thank you
Thank you for this! I don’t know how my database context got changed from one session to the next, but it did, and your post made it an easy fix that I would never have figured out.
Tony, than you. I did not know about clearing the IntelliSense cache and that was the magic for me.