How to Get SSMS to Recognize an Existing Object (Refreshing Lists in SSMS)
How to Get SSMS to Recognize an Existing Object (Refreshing Lists in SSMS)
Ever get this message in SQL Server Management Studio (SSMS) when you’re certain that the object exists?
Then it proves you right when you go ahead and execute the command anyway?
Why does SSMS complain that the object doesn’t exist when it obviously does?
This happens because SSMS does not monitor database changes made in the query window. Let’s look at an example. Let’s say you create a table using the SSMS tools—in this case, the menu that comes up when you right-click the Tables folder in SSMS Object Explorer.
Because you asked SSMS to create the table, it is aware of the new object, and it refreshes its caches automatically to include it. So, after you save the new table, you see it listed in the Tables folder, …
… you see it in Intellisense, …
… and SSMS doesn’t complain about it with a “red squiggly” as it did in the very first figure of this post.
But now let’s say you create a table using a SQL CREATE TABLE command in a query window.
SSMS doesn’t monitor changes made to the database by SQL commands, so, even though the command completed successfully and the new table now exists in the database, SSMS is not aware of it, and so it doesn’t refresh its caches and the new table doesn’t appear in the Tables folder, …
… it doesn’t appear in Intellisense, …
… and SSMS will use a red squiggly to complain about it if you reference it in a query window, just like it did in the very first figure of this post.
What to do?
Fortunately, it’s very easy to ask SSMS to update its caches. To update a folder cache, you can right-click the folder in Object Explorer and select Refresh (btw, you can also refresh individual folders, tables, columns, entire databases at once, and just about anything you see listed in Object Explorer).
Another way is to select a folder or other item in Object Explorer, then use the Refresh button at the top of the Object Explorer panel to refresh the item you select. This approach has the advantage of allowing you to refresh more than one item in Object Explorer.
That’s how you update the folders in SSMS. It is just as easy to update the Intellisense cache. Just select the Edit menu from any query window, then Intellisense, and then Refresh Local Cache or use the keystroke shortcut Ctrl-Shift-R.
Enjoy!
Peter Avila
SQL Server Instructor – Interface Technical Training
Phoenix, AZ
You May Also Like
A Simple Introduction to Cisco CML2
0 3850 0Mark Jacob, Cisco Instructor, presents an introduction to Cisco Modeling Labs 2.0 or CML2.0, an upgrade to Cisco’s VIRL Personal Edition. Mark demonstrates Terminal Emulator access to console, as well as console access from within the CML2.0 product. Hello, I’m Mark Jacob, a Cisco Instructor and Network Instructor at Interface Technical Training. I’ve been using … Continue reading A Simple Introduction to Cisco CML2
Cable Testers and How to Use them in Network Environments
0 713 1This content is from our CompTIA Network + Video Certification Training Course. Start training today! In this video, CompTIA Network + instructor Rick Trader demonstrates how to use cable testers in network environments. Let’s look at some tools that we can use to test our different cables in our environment. Cable Testers Properly Wired Connectivity … Continue reading Cable Testers and How to Use them in Network Environments
How to Build in a PSMethod to your PowerShell Code
0 72 0In this video, PowerShell instructor Jason Yoder shows how to add Methods (PSMethod) to your code using free software that’s added into the PSObject. For instructor-led PowerShell courses, see our course schedule. Microsoft Windows PowerShell Training Download the Building Methods PowerShell script</a> used in this video. <# ╔══════════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ Building Methods ║ ╟──────────────────────────────────────────────────────────────────────────────╢ … Continue reading How to Build in a PSMethod to your PowerShell Code