在SQL Server Management Studio中设置深色主题

In SQL Server Management Studio 2016, Microsoft introduced a visual setting option to choose between the Blue and Light color theme. In SSMS 2016, SSMS 2017 and the latest SSMS 18, the user can switch between the Blue or Light theme by going to Tools | Options | Environment | General | Color theme:

在SQL Server Management Studio 2016中,Microsoft引入了可视设置选项,可以在蓝色和浅色主题之间进行选择。 在SSMS 2016,SSMS 2017和最新的SSMS 18中,用户可以通过转到“ 工具” |“浅色”在蓝色或浅色主题之间切换 选项| 环境| 一般| 颜色主题

Visual experience settings of SSMS in the Options dialog

SSMS黑暗主题 (SSMS Dark theme)

Although it’s not officially supported by Microsoft, the Dark theme is also available in SQL Server Management Studio 2016, 17, and the latest 18 version. The dark theme has been very popular among SQL database administrators and developers. To enable the SSMS Dark theme, follow these simple steps.

尽管Microsoft尚未正式支持Dark主题,但SQL Server Management Studio 2016 17,最新版本18中也提供了Dark主题。 黑暗主题在SQL数据库管理员和开发人员中非常流行。 要启用SSMS Dark主题,请遵循以下简单步骤。

Close SSMS if it is running. Run any text editor as an administrator, in this case, Notepad++ is used, in order to edit the SSMS configuration file:

如果正在运行,请关闭SSMS。 以管理员身份运行任何文本编辑器,在这种情况下,使用Notepad ++来编辑SSMS配置文件:

Running Notepad++ as an administrator

The configuration (ssms.pkgundef) file is located at the following locations:

配置(ssms.pkgundef)文件位于以下位置:

SSMS 2016 (SSMS 2016)

C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio

C:\ Program Files(x86)\ Microsoft SQL Server \ 130 \ Tools \ Binn \ ManagementStudio

SSMS 17 (SSMS 17 )

C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio

C:\ Program Files(x86)\ Microsoft SQL Server \ 140 \ Tools \ Binn \ ManagementStudio

SSMS 18 (SSMS 18 )

C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE

C:\ Program Files(x86)\ Microsoft SQL Server Management Studio 18 \ Common7 \ IDE

Depending on SSMS version, locate and open the configuration file (ssms.pkgundef) in the text editor:

根据SSMS版本,在文本编辑器中找到并打开配置文件(ssms.pkgundef):

Opening the SSMS configuration file with Notepad++

Once the file is opened in the text editor, scroll down and find the section of the code under the “Remove Dark theme” heading, add “//” (without quotation marks) at the beginning of the first line like shown below, and save the file:

在文本编辑器中打开文件后,向下滚动并找到“删除深色主题”标题​​下的代码部分,在第一行的开头添加“ //”(不带引号),如下所示,然后保存文件:

SQL Server Management Studio configuration file opened in Notepad++

Once completed, start SQL Server Management Studio and the Dark color theme will be available in the Color theme drop-down box:

完成后,启动SQL Server Management Studio,然后在“颜色主题”下拉框中可以使用“深色”主题:

SSMS Dark theme option under Visual experience settings

升级问题 (Problem with upgrades)

Each upgrade of the latest generation of SSMS will set the configuration file back to its defaults. This will, of course, overwrite the tweak we made earlier and the Dark theme will no longer be available in the options.

最新一代SSMS的每次升级都会将配置文件恢复为默认值。 当然,这将覆盖我们之前所做的调整,并且“深色”主题将不再在选项中可用。

Instead of doing the same steps to enable the SSMS Dark theme each time there is an upgrade, thanks to a reader (Luka Lovre) who made a PowerShell script, there’s an easier way with the same outcome which can be achieved in just a few clicks.

不用每次升级都执行相同的步骤来启用SSMS Dark主题,这要归功于读者(Luka Lovre)编写了PowerShell脚本,而更简单的方法是只需单击几下即可获得相同的结果。

All we need to do is to run either Command Prompt or Windows PowerShell which is designed to improve the command-line and scripting. Either way, make sure to run the interpreter as an administrator or you’ll get an error message that access to the path is denied:

我们所需要做的就是运行命令提示符或Windows PowerShell,后者旨在改善命令行和脚本。 无论哪种方式,请确保以管理员身份运行解释器,否则您将收到一条错误消息,指出对路径的访问被拒绝:

Running the script in Windows PowerShell without admin permissions

I’d go with the PowerShell because, in some cases, even upon successful execution of the script in Command Prompt, the changes are not applied (the case with SSMS 17.7). So, in this example, Windows PowerShell is used.

我会选择使用PowerShell,因为在某些情况下,即使在命令提示符中成功执行了脚本,也不会应用所做的更改(SSMS 17.7就是这种情况)。 因此,在此示例中,使用Windows PowerShell。

To run the PowerShell as an administrator, click Start, type PowerShell, right-click Windows PowerShell, and then choose Run as administrator:

要以管理员身份运行PowerShell,请单击“ 开始” ,键入PowerShell,右键单击“ Windows PowerShell” ,然后选择“以管理员身份运行”

Running Windows PowerShell as administrator

Depending on the version of SSMS, copy the appropriate script into the clipboard, paste it in PowerShell and hit Enter to execute it:

根据SSMS的版本,将适当的脚本复制到剪贴板中,将其粘贴到PowerShell中,然后按Enter执行它:

SSMS 2016 (SSMS 2016)

powershell -Command "(gc 'C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\ssms.pkgundef') -replace '\[\`$RootKey\`$\\Themes\\{1ded0138-47ce-435e-84ef-9ec1f439b749}\]', '//[`$RootKey`$\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}]' | Out-File 'C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\ssms.pkgundef'"

powershell- 命令 “( gc'C :\ Program Files(x86)\ Microsoft SQL Server \ 130 \ Tools \ Binn \ ManagementStudio \ ssms.pkgundef')-替换'\ [\ $ RootKey \`$ \\ Themes \\ {1ded0138-47ce-435e-84ef-9ec1f439b749} \]','// [`$ RootKey` $ \ Themes \ {1ded0138-47ce-435e-84ef-9ec1f439b749}]'|外文件'C:\ Program Files (x86)\ Microsoft SQL Server \ 130 \ Tools \ Binn \ ManagementStudio \ ssms.pkgundef'“

SSMS 17 (SSMS 17)

powershell -Command "(gc 'C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\ssms.pkgundef') -replace '\[\`$RootKey\`$\\Themes\\{1ded0138-47ce-435e-84ef-9ec1f439b749}\]', '//[`$RootKey`$\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}]' | Out-File 'C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\ssms.pkgundef'"

powershell- 命令 “( gc'C :\ Program Files(x86)\ Microsoft SQL Server \ 140 \ Tools \ Binn \ ManagementStudio \ ssms.pkgundef')-替换'\ [\ $ RootKey \`$ \\ Themes \\ {1ded0138-47ce-435e-84ef-9ec1f439b749} \]','// [`$ RootKey` $ \ Themes \ {1ded0138-47ce-435e-84ef-9ec1f439b749}]'|外文件'C:\ Program Files (x86)\ Microsoft SQL Server \ 140 \ Tools \ Binn \ ManagementStudio \ ssms.pkgundef'“

SSMS 18 (SSMS 18)

powershell -Command "(gc 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\ssms.pkgundef') -replace '\[\`$RootKey\`$\\Themes\\{1ded0138-47ce-435e-84ef-9ec1f439b749}\]', '//[`$RootKey`$\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}]' | Out-File 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\ssms.pkgundef'"

powershell- 命令 “( gc'C :\ Program Files(x86)\ Microsoft SQL Server Management Studio 18 \ Common7 \ IDE \ ssms.pkgundef')-replace'\ [\ $$ RootKey \`$ \\ Themes \\ { 1ded0138-47ce-435e-84ef-9ec1f439b749} \]','// [`$ RootKey` $ \ Themes \ {1ded0138-47ce-435e-84ef-9ec1f439b749}]'|外文件'C:\ Program Files( x86)\ Microsoft SQL Server Management Studio 18 \ Common7 \ IDE \ ssms.pkgundef'“

The successfully executed script in Windows PowerShell to enable SSMS Dark theme

There will be no return message that the operation succeeded except the blinking cursor on a new line.

除了新行上闪烁的光标外,没有返回消息表明操作成功。

Once either of those two methods is done, startup SSMS, and change the visual appearance to dark. Here’s how it looks:

一旦完成这两种方法中的任何一种,就启动SSMS,并将视觉外观更改为深色。 外观如下:

SSMS Dark theme

Note: As I mentioned before, the SSMS Dark theme is not officially supported and it probably never be and that’s why it is disabled by default. There might be some visual deviations e.g. white background in the Object Explorer, Results grid, etc.

注意 :如前所述,SSMS Dark主题不受官方支持,并且可能永远不会被支持,这就是默认情况下禁用它的原因。 可能会有一些视觉偏差,例如,对象浏览器中的白色背景,结果网格等。

To see how we’ve implemented visual themes in our products, see this article: Visual themes in ApexSQL tools

若要查看我们如何在产品中实现视觉主题,请参阅本文: ApexSQL工具中的视觉主题

翻译自: https://www.sqlshack.com/setting-up-the-dark-theme-in-sql-server-management-studio/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值