Thursday, June 14, 2012

SQL Intellisense Refresh

Often time when there are some schema changes, SQL intellisense (in SSMS or Visual Studio SQL Project) does not get updated. Here is an example,

CREATE TABLE dbo.TestTable
(
 ID INT NOT NULL
);

ALTER TABLE dbo.TestTable
ADD Customer varchar(50) NOT NULL;

SELECT TT.Customer
FROM dbo.TestTable TT;

Intellisense doesn't detect the new added column and it underlines the column 'Name' as an error (If you have enabled intellisense and error underline option checked). In order to update the SQL intellisense, go to menu,

Edit > Intellisense > Refresh Local Cache

Or use keyboard shortcut Ctrl+Shirft+R for SSMS, and Ctrl+K, Ctrl+R for Visual Studio.

Now, the intellisense is updated and no underline error!

In some scenario like connecting server instance from your own work station, it may take a few seconds for the intellisense to refresh with the changes. I have only tested this on SQL Server 2008 R2 SSMS and Visual Studio 2010.

Google+