ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

ssms中怎么设置自增

This article explains the process of defining custom color codes for SQL Server connections in SSMS.

本文介绍了在SSMS中为SQL Server连接定义自定义颜色代码的过程。

介绍 (Introduction)

DBAs or developers might work simultaneously with different environments such as production, UAT, staging, development. Sometimes, you might execute a query in a different environment in case you miss to check the environment. We should always be careful as accidentally query execution might put you in trouble. For example, in a development environment, we might drop a few objects without worrying much. If the same object exists in the production database as well and you accidentally run the query in production, you are in big trouble.

DBA或开发人员可能会同时使用不同的环境,例如生产,UAT,登台,开发。 有时,您可能会在其他环境中执行查询,以防您错过检查该环境的机会。 我们应该始终小心,因为意外执行查询可能会给您带来麻烦。 例如,在开发环境中,我们可以放一些对象而不必担心。 如果生产数据库中也存在相同的对象,而您在生产中不小心运行了查询,则将遇到很大麻烦。

指定SSMS连接的自定义颜色 (Specify custom colors for SSMS connection)

Be careful while running any query. You can verify the connected instance using the status bar of SSMS. Each new query window provides the connection details.

运行任何查询时请小心。 您可以使用SSMS的状态栏来验证连接的实例。 每个新的查询窗口均提供连接详细信息。

In the following screenshot, we verify connected SQL instance as well as an authenticated user:

在以下屏幕截图中,我们将验证连接SQL实例以及经过身份验证的用户:

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

SSMS provides a solution for us to determine the environment as per the environment color coding. For example, we can set a red color for production, yellow for development, etc.

SSMS为我们提供了一种根据环境颜色编码确定环境的解决方案。 例如,我们可以为生产设置红色,为开发设置黄色,等等。

Usually, we launch SSMS, specify the SQL instance, and connect to the respective SQL Server.

通常,我们启动SSMS,指定SQL实例,然后连接到相应SQL Server。

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

Click on Options, and you get various configuration tabs in SSMS.

单击选项,您将在SSMS中获得各种配置选项卡。

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

Let’ have a quick overview of these tabs of SSMS:

让我们快速浏览一下SSMS的以下标签:

  • Login: It is the default connection window of SSMS. We specify the following configurations:
    • Server type: Type of the SQL Service we want to connect, such as database engine, Analysis Service, Integration services, and reporting services
    • Server Name: It is the SQL instance name. For a default instance, we can specify a dot(.) or MSSQLSERVER. For a named instance, enter the SQL instance in the format of [Server\SQLInstance]. If you use a SQL port other than the default, specify that port number as well as [Server\SQLInstance:Port]
    • Authentication: We can choose the authentication mechanism, either Windows or SQL authentication. For SQL authentication, specify SQL user and password details

    登录 :这是SSMS的默认连接窗口。 我们指定以下配置:
    • 服务器类型:我们要连接SQL服务的类型,例如数据库引擎,Analysis Service,集成服务和报告服务
    • 服务器名称:这是SQL实例名称。 对于默认实例,我们可以指定点(。)或MSSQLSERVER。 对于命名实例,以[Server \ SQLInstance]格式输入SQL实例。 如果使用默认端口以外SQL端口,请指定该端口号以及[Server \ SQLInstance:Port]
    • 身份验证:我们可以选择Windows或SQL身份验证两种身份验证机制。 对于SQL身份验证,请指定SQL用户和密码详细信息
  • Always Encrypted: We use this option if using SQL Server Always Encrypted feature

    始终加密:如果使用“ SQL Server始终加密”功能,则使用此选项
  • Additional Connection parameters

    其他连接参数
  • Connection Properties: In this connection properties, We can use the following optional configurations

    ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

    • Connect to database: If we want to connect to a specific database, we can use this option, browse the server and select the required database. If we do not specify any database, the user gets a connection to the default database specified in the SQL logins

    • Network protocol and network packet sizes: Here, we can choose the network protocol and packet size. You should change this property only on specific requirements
    • Connection time out and execution time out: We can configure the connection and execution time outs value in seconds in these values
    • Encrypt connection: if we use encrypted SQL connections, we can put a tick on this. Your SQL instance should be configured for the encrypted connection before using this option
    • Use Custom color: Usually, we do not use this option much, but it can prevent us from accidental query execution in the wrong SQL instance

    连接属性:在此连接属性中,我们可以使用以下可选配置

    ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

    • 连接到数据库:如果要连接到特定数据库,则可以使用此选项,浏览服务器并选择所需的数据库。 如果我们不指定任何数据库,则用户将连接到SQL登录名中指定的默认数据库

    • 网络协议和网络数据包大小:在这里,我们可以选择网络协议和数据包大小。 您仅应在特定要求下更改此属性
    • 连接超时和执行超时:我们可以在这些值中以秒为单位配置连接和执行超时值
    • 加密连接:如果我们使用加密SQL连接,则可以在此打勾。 使用此选项之前,应为加密连接配置SQL实例
    • 使用自定义颜色:通常,我们很少使用此选项,但是它可以防止我们在错误SQL实例中意外执行查询

Put a check on Use custom color and select a color from the available colors:

选中“使用自定义颜色”,然后从可用颜色中选择一种颜色:

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

Now, connect the database instance and view the query pane. Notice the difference. You get a custom color code for the status bar. This way, you can easily visualize that this connection belongs to a production SQL instance. Similarly, you can configure color codes for other databases while connecting using SSMS:

现在,连接数据库实例并查看查询窗格。 注意差异。 您将获得状态栏的自定义颜色代码。 这样,您可以轻松地形象地看到此连接属于生产SQL实例。 同样,您可以在使用SSMS连接时为其他数据库配置颜色代码:

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

本地服务器组和自定义状态栏颜色 (Local Server groups and custom status bar color)

In the previous step, we specified the custom status bar color while connecting it using SSMS. Usually, DBAs register the supported SQL instances using the local server groups. We can create multiple server groups in various groups such as application group, environment group depending upon an individual’s requirements.

在上一步中,我们在使用SSMS连接自定义状态栏颜色时指定了该颜色。 通常,DBA使用本地服务器组注册受支持SQL实例。 我们可以根据个人的需求在不同的组(例如应用程序组,环境组)中创建多个服务器组。

We can click on the Local Server Groups from the registered servers, as shown below:

我们可以从注册的服务器上单击本地服务器组 ,如下所示:

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

Right-click on the Local Server Groups and click on the New Server Group. Specify the group name (mandatory) and group description (optional):

右键单击本地服务器组 ,然后单击新服务器组。 指定组名(必填)和组描述(可选):

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

Similarly, create another group Staging:

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

同样,创建另一个组暂存:

We have two local server groups, as shown below:

我们有两个本地服务器组,如下所示:

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

We can register the servers in the individual group. To register a server, right-click on the group name and click New Server Registration:

我们可以在各个组中注册服务器。 要注册服务器,请右键单击组名,然后单击“ 新服务器注册”

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

It opens the SSMS connection window. We can define the SQL Server connection along with server color coding. Save the connection, and it reflects in the corresponding server group:

它打开SSMS连接窗口。 我们可以定义SQL Server连接以及服务器颜色编码。 保存连接,它反映在相应的服务器组中:

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

In the following screenshot, we see both production and staging local server group contains server registered. We have defined different color codes for the ribbon bar while saving the connection. The benefit of using a local server group is that it is a one-time activity. Once we have defined connection properties, we can easily connect to that instance group without any additional configurations:

在以下屏幕截图中,我们看到生产和暂存本地服务器组都包含已注册的服务器。 保存连接时,我们为功能区栏定义了不同的颜色代码。 使用本地服务器组的好处是它是一次性活动。 定义连接属性后,无需任何其他配置即可轻松连接到该实例组:

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

Now, connect to servers from both production and staging local server groups. Open a new query window in both connections and notice the different color codes for both instances:

现在,从生产和暂存本地服务器组连接到服务器。 在两个连接中打开一个新的查询窗口,并注意两个实例的不同颜色代码:

ssms中怎么设置自增_如何在SSMS状态栏中设置自定义颜色

重要事项 (Important points)

  • We can customize color codes for the database engine connections. We cannot use it for Analysis Services, Reporting Services, and Integration

    我们可以为数据库引擎连接定制颜色代码。 我们不能将其用于Analysis Services,Reporting Services和集成
  • Ribbon bar color codes is a local SSMS feature. If you use different SSMS, you will get default color codes

    色带条颜色代码是本地SSMS功能。 如果您使用其他SSMS,则会获得默认的颜色代码
  • You should use different colors for a separate environment to avoid any confusion

    您应该在单独的环境中使用不同的颜色,以避免造成混淆

结论 (Conclusion)

You might have heard a famous saying – “Prevention Is Better Than Cure”. It applies to databases as well. You should always check the connections before executing a query. You can also use this article reference for customizing the ribbon bar color codes as per the environment in SSMS.

您可能已经听过一句名言:“预防胜于治疗”。 它也适用于数据库。 在执行查询之前,应始终检查连接。 您还可以根据SSMS中的环境使用本文参考来自定义功能区颜色代码。

翻译自: https://www.sqlshack.com/how-to-set-custom-colors-in-the-ssms-status-bar/

ssms中怎么设置自增