Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon

Toolbox - When Intellisense Doesn't See Your New Object from Blog Posts - SQLServerCentral

Save for later
  • 2 min read
  • 11 Dec 2020

article-image

I was just working on a new SQL job, and part of creating the job was adding a few new tables to our DBA maintenance database to hold data for the job.  I created my monitoring queries, and then created new tables to hold that data 


One tip - use SELECT...INTO as an easy way to create these types of tables - create your query and then add a one-time INTO clause to create the needed object with all of the appropriate column names, etc.
toolbox-when-intellisense-doesnt-see-your-new-object-from-blog-posts-sqlservercentral-img-0
https://i.redd.it/1wk7ki3wtet21.jpg

SELECT DISTINCT SERVERPROPERTY('ServerName') as Instance_Name
, volume_mount_point as Mount_Point
, cast(available_bytes/1024.0/1024.0/1024.0 as decimal(10,2)) as Available_GB
, cast(total_bytes/1024.0/1024.0/1024.0 as decimal(10,2)) as Total_GB
, cast((total_bytes-available_bytes)/1024.0/1024.0/1024.0 as decimal(10,2)) as Used_GB
, cast(100.0*available_bytes/total_bytes as decimal(5,2)) as Percent_Free
, GETDATE() as Date_Stamp
INTO Volume_Disk_Space_Info
FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS vfs      
INNER JOIN sys.master_files AS mf WITH (NOLOCK)      
ON vfs.database_id = mf.database_id AND vfs.file_id = mf.file_id  
CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.FILE_ID)   
order by volume_mount_point

I thought at this point that everything was set, until I tried to write my next statement...

toolbox-when-intellisense-doesnt-see-your-new-object-from-blog-posts-sqlservercentral-img-1
The dreaded Red Squiggle of doom!
I tried to use an alias to see if Intellisense would detect that - no luck.
toolbox-when-intellisense-doesnt-see-your-new-object-from-blog-posts-sqlservercentral-img-2
Some Google-Fu brought me to the answer on StackOverflow - there is an Intellisense cache that sometimes needs to be refreshed.
The easiest way to refresh the cache is simply a CTRL-SHIFT-R, but there is also a menu selection in SSMS to perform the refresh:
toolbox-when-intellisense-doesnt-see-your-new-object-from-blog-posts-sqlservercentral-img-3

Edit>>Intellisense>>Refresh Local Cache


In my case, once I performed the CTRL-SHIFT-R, the red squiggles disappeared!

toolbox-when-intellisense-doesnt-see-your-new-object-from-blog-posts-sqlservercentral-img-4
https://memegenerator.net/img/instances/61065657/you-see-its-magic.jpg

Hope this helps!

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime

The post Toolbox - When Intellisense Doesn't See Your New Object appeared first on SQLServerCentral.