脚本化创建后,SQL Management Studio 无法识别表存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2201151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 05:17:19  来源:igfitidea点击:

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

sqlsql-serverssms

提问by jamone

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.

因此,如果我在数据库上点击刷新后在 SQL Management Studio 的查询编辑器中创建一个新表,我可以看到并使用该表。但是,如果我想从查询编辑器中运行另一个查询引用该表,它不会重新识别该表是否存在。我试过在数据库级别和表级别点击刷新,但没有区别。但是,如果我退出管理工作室然后重新打开它会显示正常。

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

这不能说州不存在。状态也没有出现在智能感知中。我该怎么做

回答by

Press Ctrl-Shift-R to refresh the intellisense.

按 Ctrl-Shift-R 刷新智能感知。

回答by Roberto

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...

使用菜单的好处是,您将学习一些新的 Intellisense 热键...

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

架构更改后 SQL Server Management Studio Intellisense 不起作用

回答by Randy Minder

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

你可能做了我一直做的事情。我经常在连接到错误的数据库或默认数据库时创建一个表。对我来说,默认数据库是“master”,所以我的主数据库中有很多垃圾:)

Randy

兰迪

回答by Terry

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

我右键单击表并从上下文相关菜单中选择刷新(Ctrl-R 也可以)