ssms2008 代码自动提示_使用 SSMS 的提示和技巧 - SQL Server Management Studio (SSMS) | Microsoft Docs...

使用 SQL Server Management Studio (SSMS) 的提示和技巧Tips and tricks for using SQL Server Management Studio (SSMS)

03/13/2018

本文内容

本文介绍了一些使用 SQL Server Management StudioSQL Server Management Studio (SSMS) 的提示和技巧。This article gives you some tips and tricks for using SQL Server Management StudioSQL Server Management Studio (SSMS). 本文介绍如何:This article shows you how to:

注释/取消注释 Transact-SQL (T-SQL) 文本Comment/uncomment your Transact-SQL (T-SQL) text

缩进文本Indent your text

在对象资源管理器中筛选对象Filter objects in Object Explorer

访问 SQL ServerSQL Server 错误日志Access your SQL ServerSQL Server error log

查找 SQL ServerSQL Server 实例的名称Find the name of your SQL ServerSQL Server instance

先决条件Prerequisites

若要测试本文提供的步骤,必须有 SQL Server Management StudioSQL Server Management Studio、对 SQL Server 的访问权限,以及 AdventureWorks 数据库。To test out the steps provided in this article, you need SQL Server Management StudioSQL Server Management Studio, access to a SQL server, and an AdventureWorks database.

注释/取消注释 T-SQL 代码Comment/uncomment your T-SQL code

可使用工具栏中的“注释”按钮注释和取消注释部分文本 。You can comment and uncomment portions of your text by using the Comment button on the toolbar. 系统不会执行已注释掉的文本。Text that is commented out is not executed.

打开 SQL Server Management StudioSQL Server Management Studio。Open SQL Server Management StudioSQL Server Management Studio.

连接到 SQL Server。Connect to your SQL server.

打开“新建查询”窗口。Open a New Query window.

将以下 Transact-SQLTransact-SQL 代码粘贴到文本窗口。Paste the following Transact-SQLTransact-SQL code in your text window.

USE master

GO

-- Drop the database if it already exists

IF EXISTS (

SELECT name

FROM sys.databases

WHERE name = N'TutorialDB'

)

DROP DATABASE TutorialDB

GO

CREATE DATABASE TutorialDB

GO

ALTER DATABASE [TutorialDB] SET QUERY_STORE=ON

GO

突出显示文本的“更改数据库”部分,然后选择工具栏中的“注释”按钮 :Highlight the Alter Database portion of the text, and then select the Comment button on the toolbar:

选择“执行”运行取消注释的文本部分 。Select Execute to run the uncommented portion of the text.

突出显示除“更改数据库”命令之外的所有内容,然后选择“注释”按钮 :Highlight everything except for the Alter Database command, and then select the Comment button:

备注

注释的文本的键盘快捷方式是 CTRL + K,CTRL + C 。The keyboard shortcut to comment text is CTRL + K, CTRL + C.

突出显示文本的“更改数据库”部分,然后选择工具栏中的“取消注释”按钮以取消注释 :Highlight the Alter Database portion of the text, and then select the Uncomment button to uncomment it:

备注

取消注释的文本的键盘快捷方式是 CTRL + K,CTRL + U 。The keyboard shortcut to uncomment text is CTRL + K, CTRL + U.

选择“执行”运行取消注释的文本部分 。Select Execute to run the uncommented portion of the text.

缩进文本Indent your text

可使用工具栏上的缩进按钮增加或减少文本的缩进。You can use the indentation buttons on the toolbar to increase or decrease the indent of your text.

打开“新建查询”窗口。Open a New Query window.

将以下 Transact-SQLTransact-SQL 代码粘贴到文本窗口:Paste the following Transact-SQLTransact-SQL code in your text window:

USE master

GO

--Drop the database if it already exists

IF EXISTS (

SELECT name

FROM sys.databases

WHERE name = N'TutorialDB'

)

DROP DATABASE TutorialDB

GO

CREATE DATABASE TutorialDB

GO

ALTER DATABASE [TutorialDB] SET QUERY_STORE=ON

GO

突出显示文本的“更改数据库”部分,然后选择工具栏上的“增加缩进”按钮以向前移动此文本 :Highlight the Alter Database portion of the text, and then select the Increase Indent button on the toolbar to move this text forward:

再次突出显示文本的“更改数据库”部分,然后选择“减少缩进”按钮以向后移动此文本 。Highlight the Alter Database portion of the text again, and then select the Decrease Indent button to move this text back.

在对象资源管理器中筛选对象Filter objects in Object Explorer

在具有多个对象的数据库中,可以使用筛选功能来搜索特定表、视图等。本节介绍如何筛选表,但可在对象资源管理器中的任何其他节点中使用以下步骤:In databases that have many objects, you can use filtering to search for specific tables, views, etc. This section describes how to filter tables, but you can use the following steps in any other node in Object Explorer:

连接到 SQL Server。Connect to your SQL server.

展开“数据库” > “AdventureWorks” > “表” 。Expand Databases > AdventureWorks > Tables. 此时将显示数据库中的所有表。All the tables in the database appear.

右键单击“表”,然后选择“筛选器” > “筛选器设置” :Right-click Tables, and then select Filter > Filter Settings:

在“筛选器设置”窗口中,可以修改以下某些筛选器设置 :In the Filter Settings window, you can modify some of the following filter settings:

按名称筛选:Filter by name:

按架构筛选:Filter by schema:

若要清除筛选器,请右键单击“表”,然后选择“删除筛选器” 。To clear the filter, right-click Tables, and then select Remove Filter.

访问 SQL Server 错误日志Access your SQL Server error log

错误日志是一个文件,其中包含 SQL ServerSQL Server 实例中所发生操作的相关详细信息。The error log is a file that contains details about things that occur in your SQL ServerSQL Server instance. 可浏览和查询 SSMS 中的错误日志。You can browse and query the error login SSMS. 错误日志是位于磁盘上的日志文件。The error log is a .log file that's located on your disk.

在 SSMS 中打开错误日志Open the error log in SSMS

连接到你的 SQL ServerSQL Server。Connect to your SQL ServerSQL Server.

展开“管理” > “SQL Server 日志” 。Expand Management > SQL Server Logs.

右键单击“当前”错误日志,然后选择“查看 SQL Server 日志” :Right-click the Current error log, and then select View SQL Server Log:

在 SSMS 中查看查询日志Query the error log in SSMS

连接到 SQL Server。Connect to your SQL server.

打开“新建查询”窗口。Open a New Query window.

将以下 Transact-SQLTransact-SQL 代码粘贴到查询窗口:Paste the following Transact-SQLTransact-SQL code in your query window:

sp_readerrorlog 0,1,'Server process ID'

将单引号中的文本修改为要搜索的文本。Modify the text in the single quotes to text you want to search for.

执行查询然后查看结果:Execute the query, and then review the results:

如果连接到 SQL Server,请查找错误日志位置Find the error log location if you're connected to SQL Server

连接到你的 SQL ServerSQL Server。Connect to your SQL ServerSQL Server.

打开“新建查询”窗口。Open a New Query window.

将以下 Transact-SQLTransact-SQL 代码粘贴到查询窗口,然后选择“执行”:Paste the following Transact-SQLTransact-SQL code in your query window, and then select Execute:

SELECT SERVERPROPERTY('ErrorLogFileName') AS 'Error log file location'

结果将显示文件系统中错误日志的位置:The results show the location of the error log in the file system:

如果无法连接到 SQL Server,请查找错误日志位置Find the error log location if you can't connect to SQL Server

你的 SQL ServerSQL Server 错误日志的路径可能有所不同,具体取决于你的配置设置。The path for your SQL ServerSQL Server error log can vary depending on your configuration settings. 可以在 SQL Server 配置管理器内的启动参数中找到错误日志位置的路径。The path for the error log location can be found in the startup parameters within the SQL Server Configuration Manager. 请按照以下步骤来找到标识 SQL ServerSQL Server 错误日志位置的相关启动参数。Follow the steps below to locate the relevant startup parameter identifying the location of your SQL ServerSQL Server error log. 你的路径可能与以下指示的路径有所不同 。Your path may vary from the path indicated below.

打开“SQL Server 配置管理器”。Open SQL Server Configuration Manager.

展开“服务” 。Expand Services.

右键单击你的 SQL ServerSQL Server 实例,然后选择“属性”:Right-click your SQL ServerSQL Server instance, and then select Properties:

选择“启动参数”选项卡 。Select the Startup Parameters tab.

在“现有参数”区域中,“-e”后面的路径是错误日志的位置 :In the Existing Parameters area, the path after "-e" is the location of the error log:

此位置中包含多个错误日志文件。There are several error log files in this location. 当前错误日志的文件名以 *.log 结尾。The file name that ends with *.log is the current error log file. 以前的日志文件的文件名以数字结尾。File names that end with numbers are previous log files. 每次重新启动 SQL Server 时都会创建一个新日志。A new log is created every time the SQL server restarts.

在记事本中打开 errorlog.log 文件。Open the errorlog.log file in Notepad.

查找 SQL Server 实例名称Find SQL Server instance name

在连接到 SQL Server 之前和之后,有几个选项可用于查找 SQL ServerSQL Server 的名称。You have a few options for finding the name of your SQL server before and after you connect to SQL ServerSQL Server.

连接到 SQL Server 之前Before you connect to SQL Server

Follow the steps to locate the SQL Server error log on disk. 你的路径可能与下图中的路径有所不同。Your path may vary from the path in the image below.

在记事本中打开 errorlog.log 文件。Open the errorlog.log file in Notepad.

搜索文本“服务器名称是” 。Search for the text Server name is.

单引号中列出的所有内容都是将连接到的 SQL ServerSQL Server 实例的名称:Whatever is listed in the single quotes is the name of the SQL ServerSQL Server instance that you'll be connecting to:

名称的格式为 HOSTNAME\INSTANCENAME。The format of the name is HOSTNAME\INSTANCENAME. 如果只看到了主机名,然后已安装了默认实例,则实例名称是 MSSQLSERVER。If you see only the host name, then you've installed the default instance and your instance name is MSSQLSERVER. 连接到默认实例时,只需输入主机名以连接到 SQL Server。When you connect to a default instance, the host name is all you need to enter to connect to your SQL server.

连接到 SQL Server 时When you're connected to SQL Server

连接到 SQL ServerSQL Server 时,可在三个位置找到服务器名称:When you're connected to SQL ServerSQL Server, you can find the server name in three locations:

服务器名称将在“对象资源管理器”中列出:The name of the server is listed in Object Explorer:

服务器名称将在查询窗口中列出:The name of the server is listed in the Query window:

服务器名称将在“属性”中列出 。The name of the server is listed in Properties.

在“视图”菜单上,选择“属性窗口” :In the View menu, select Properties Window:

如果连接到别名或可用性组侦听程序If you're connected to an alias or Availability Group listener

如果连接到别名或可用性组侦听程序,则将在“对象资源管理器”和“属性”中显示该信息。If you're connected to an alias or to an Availability Group listener, that information appears in Object Explorer and Properties. 在这种情况下,SQL ServerSQL Server 名称可能不是显而易见的,并且必须进行查询:In this case, the SQL ServerSQL Server name might not be readily apparent, and must be queried:

连接到 SQL Server。Connect to your SQL server.

打开“新建查询”窗口。Open a New Query window.

将以下 Transact-SQLTransact-SQL 代码粘贴到窗口中:Paste the following Transact-SQLTransact-SQL code in the window:

select @@Servername

查看查询结果,确定连接到的 SQL ServerSQL Server 实例的名称:View the results of the query to identify the name of the SQL ServerSQL Server instance you're connected to:

后续步骤Next steps

熟悉 SSMS 的最好方式是进行实践演练。The best way to get acquainted with SSMS is through hands-on practice. 这些教程 和操作说明 文章可帮助你使用 SSMS 的各种功能。These tutorial and how-to articles help you with various features available within SSMS. 这些文章教你如何管理 SSMS 组件,以及如何查找常用功能。These articles teach you how to manage the components of SSMS and how to find the features that you use regularly.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/336663.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

递增星号打印解析

#include<iostream> using namespace std;//输出一个5X5递增*号图形 //分析首先需要打印出5行&#xff0c;每行打印的*号数量与当前行数相同int main() {for (int i 1; i <5; i)//循环打印确定行数为5{for (int j 0;j<i;j)//从每行第一个位置开始打印&#xff0c;…

计算机接口控制采集时序图,自动站实时数据质量控制

自动站实时数据质量控制利用极值法、比较法、综合(本文共2页)阅读全文>>通过2次自动站实时数据质量控制失败的案例,分析总结了自动气象站实时数据质量控制的经验教训。结果表明:(1)值班员必须严格执行地面气象观测规范和各项规章制度;必须充分认识建立和运行实时自动气象…

jpa语法错误_JPA陷阱/错误

jpa语法错误根据我在帮助团队和进行培训方面的经验&#xff0c;这是我遇到的一些陷阱/错误&#xff0c;它们在使用JPA的基于Java的系统中引起了一些问题。 需要一个公共的无参数构造函数 始终使用双向关联/关系 将OneToMany用于可能庞大的集合 需要一个公共的无参数构造函数…

python源码文件以什么格式结尾结尾_查看python源码,发现里面的函数都以pass结尾,那么意义何在?...

例如&#xff1a;class str(object):"""str(object) -> strstr(bytes_or_buffer[, encoding[, errors]]) -> strCreate a new string object from the given object. If encoding orerrors is specified, then the object must expose a data bufferthat …

java流式传输对象_使用Java 8在地图上流式传输

java流式传输对象在本文中&#xff0c;我将向您展示如何在标准Java映射上有效地实现Speedment Open Source流&#xff0c;并将Stream接口扩展为MapStream&#xff01; 即使在复杂的情况下&#xff0c;此添加将使保持流的具体性和可读性变得更加容易。 希望这将允许您继续流式传…

计算机学术硕士课题,硕士学术论文选题的原则分析

硕士学术论文选题的原则分析选题作为硕士学术论文写作过程的第一步&#xff0c;也是最关键的一步&#xff0c;直接影响到论文写作整个过程中&#xff0c;包括资料收集&#xff0c;发现问题&#xff0c;解决问题等一系列工作&#xff0c;决定了整篇论文的成败。硕士学术论文是对…

选择排序与冒泡排序的区别

冒泡排序&#xff1a;冒泡排序&#xff08;BubbleSort&#xff09;的基本概念是&#xff1a;依次比较相邻的两个数&#xff0c;将小数放在前面&#xff0c;大数放在后面。即在第一趟&#xff1a;首先比较第1个和第2个数&#xff0c;将小数放前&#xff0c;大数 放后。然后比较第…

冒泡排序 自带时间复杂度测试

#include<iostream> #include<time.h> using namespace std;void Sort(int List[], int n);int main() {int a[10000];int k, j;// 设置种子srand((unsigned)time(NULL));/* 生成 10 个随机数 */for (k 0; k < 10000; k){// 生成实际的随机数j rand();a[k] j…

独占线程太多怎么办_电脑内存被占用太多怎么办?

1、禁用闲置的IDE通道右键点击“我的电脑-属性”&#xff0c;然后点击“硬件”接着点击“设备管理器”&#xff0c;在其中打开“IDE ATA/PATA控制器”然后分别进入主要和次要IDE通道&#xff0c;选择“高级设置”&#xff0c;在这里找到“当前传送模式”为“不适用”的一项&…

计算机net use命令使用,网络命令net之net use应用

echo offnet use LPT1: "123456" /user:pingpai /persistent:no以上为批处理文件 "打印.bat"脚本。先介绍net use命令&#xff0c;最后看这个脚本是什么意思。以下内容来自net help use的结果。C:\Documents and Settings\ppb>net help use此命令的语…

记录日志的测试软件_教程:测试期间的日志记录

记录日志的测试软件日志记录是一种流行的解决方案&#xff0c;用于显示软件在运行时的运行状况。 但是&#xff0c;当我们使用jUnit / TestNG对应用程序进行单元测试时&#xff0c;日志记录会怎样&#xff1f; 在自动化测试执行期间&#xff0c;我们通常不希望看到日志记录消…

选择排序 自带时间复杂度分析

从当前未排序的整数中找到最小的整数&#xff0c;将它放在已排序的整数列表的最后。 #include<iostream> #include<time.h> using namespace std;void Sort(int List[], int n);int main() {int a[10000];int k, j;// 设置种子srand((unsigned)time(NULL));/* 生成…

oracle11g支持xp吗_拔掉U盘前一定需要安全弹出吗?

相信每一个使用过U盘的人&#xff0c;都经历过不安全弹出USB设备就直接拔掉&#xff0c;然后被电脑无情提示没有正确弹出USB设备的状况。拔掉U盘前点击安全弹出&#xff0c;已经成了一种默认的操作。那么&#xff0c;问题来了&#xff0c;拔掉U盘前真的需要安全弹出吗&#xff…

yili邮箱服务器配置,手把手教 个人SMTP服务器的配置 -电脑资料

导读&#xff1a;&#xff0c;因此我们要手工添加&#xff0c;管理员身份登录Windows Server 2003 系统。依次进入“控制面板→添加或删除程序→添加/删除Windows组件”&#xff0c;在弹出的“Windows组件向导”对话框中选中“电子邮件服务”选项&#xff0c;点击“详细信息”按…

java中使用kotlin_在Kotlin中使用libGDX

java中使用kotlin最近&#xff0c;我一直在阅读有关不同语言的信息&#xff0c;以及它们可以为已经拥挤的软件开发人员带来什么&#xff0c;并且一种语言对我来说很突出&#xff1a;Kotlin。 &#xff08; https://kotlinlang.org/ &#xff09; 这是一种相对较新的语言&#…

单链表的各种操作

#include<iostream> #define _CRT_SECURE_NO_WARNINGS using namespace std; typedef int DATA;struct SNode //定义节点 {DATA data;SNode* pNext; }; class CList //创建一个链表类 {SNode* m_hHead; //链表初始化char m_name[20];public:CL…

linux双显卡配置_Linux系统怎么配置双显卡?

感谢脚本之家网友鸢一雨音 的投稿众所周知&#xff0c;自从高性能独立图形处理器出现之后&#xff0c;很多便携式计算机就会采取一种双显卡的设计&#xff1a;节能的核心图形处理器用于渲染常规的桌面环境&#xff0c;而高性能的独立图形处理器则负责渲染高需求的应用程序。这种…

同时防服务器维修,加强服务器日常运维,避免宕机灾难发生

原标题&#xff1a;加强服务器日常运维&#xff0c;避免宕机灾难发生服务器作为我们日常网络的支撑&#xff0c;可以说是24小时的全天候运转。在这种无休止的“加班”的状态下&#xff0c;服务器必然容易出问题&#xff0c;一旦发生服务器宕机就会造成整个网络的瘫痪&#xff0…

java动态代理_Java动态代理

java动态代理代理是一种设计模式。 当我们想添加或修改现有类的某些功能时&#xff0c;我们创建并使用代理对象。 使用代理对象而不是原始对象。 通常&#xff0c;代理对象具有与原始对象相同的方法&#xff0c;并且在Java代理类中&#xff0c;通常会extend原始类。 代理具有原…

建立能持续处理请求的Server端改造

#include<iostream> #include<Windows.h> using namespace std;int main() {//初始化ws2_32.dllWORD ver MAKEWORD(2, 2);WSADATA wsaData;WSAStartup(ver, &wsaData);//对应WSACleanup的调用//1.建立一个socketSOCKET _sock ::socket(AF_INET, SOCK_STREAM,…