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

Viewed 52654

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

4 Answers

Press Ctrl-Shift-R to refresh the intellisense.

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 :)

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

Related