SQL Management Studio won't recognize a table exists after scripted create

SqlSql ServerSsms

Sql Problem Overview


So if I create a new table in the query editor in SQL Management Studio after hitting refresh on the DB I can see and work with that table. However if I want to run another query referencign that table from withen the query editor it doesn't reconize that table exists. I've tried hitting refresh at the DB level, and the table level but it makes no difference. However if I quit the management studio then reopen it shows up fine.

USE [DataBaseName]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[States](
	[StateAbbreviation] [nchar](2) NOT NULL,
	[StateFullName] [nchar](30) NULL,
GO

So I run that and then run this.

INSERT INTO States
SELECT *
FROM ExistingStatesTable

This fails saying that States doesn't exist. Also States doesn't show up in the intelisense. What should I do to

Sql Solutions


Solution 1 - Sql

Press Ctrl-Shift-R to refresh the intellisense.

Solution 2 - Sql

If you prefer, you can use the menu to refresh the cache:

Edit>Intellisense>Refresh Local Cache

The good thing using the menu, is that you will learn some new Intellisense hot-keys...

SQL Server Management Studio Intellisense doesn’t work after schema changes

Solution 3 - Sql

You probably did what I always do. I often create a table while connected to the wrong database, or the default database. For me, the default database is 'master' so I have a lot of garbage in my master DB :)

Randy

Solution 4 - Sql

I right-click on the Tables and Select Refresh from the context-sensitive menu (Ctrl-R works too)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjamoneView Question on Stackoverflow
Solution 1 - Sqluser121301View Answer on Stackoverflow
Solution 2 - SqlRobertoView Answer on Stackoverflow
Solution 3 - SqlRandy MinderView Answer on Stackoverflow
Solution 4 - SqlTerryView Answer on Stackoverflow