ssms,新建查询设置字体_如何在SSMS查询编辑器中使用SQLCMD命令

ssms,新建查询设置字体

SQLCMD Mode allows creating, testing, executing SQLCMD commands or scripts in SQL Server Management Studio directly in the query editor. This option is available since SQL Server 2005.

SQLCMD模式允许直接在查询编辑器中在SQL Server Management Studio中创建,测试,执行SQLCMD命令或脚本。 从SQL Server 2005开始,此选项可用。

This article will explain some of the SQLCMD script keywords that the Database Engine Query Editor supports.

本文将解释数据库引擎查询编辑器支持的一些SQLCMD脚本关键字。

To write or edit SQLCMD scripts in the query editor, the SQLCMD mode needs to be enabled. By default, this mode is turned off.

要在查询编辑器中编写或编辑SQLCMD脚本,需要启用SQLCMD模式。 默认情况下,此模式是关闭的。

To enable SQLCMD mode, click the SQLCMD Mode option under the Query menu:

若要启用SQLCMD模式,请单击“ 查询”菜单下的“ SQLCMD模式”选项:

Another way to enable the SQLCMD Mode is by using a combination of keys ALT+Q+M from the keyboard.

启用SQLCMD模式的另一种方法是组合使用键盘上的ALT + Q + M键。

In SSMS, there is an option to set the query windows to be opened in the SQLCMD mode by default. To do that, go to the SSMS main menu and under the Tools menu choose the Options command:

在SSMS中,有一个选项可以设置默认情况下在SQLCMD模式下打开查询窗口。 为此,请转到SSMS主菜单,然后在“ 工具”菜单下选择“ 选项”命令:

This will open the Options window. From the list, choose the Query Execution -> SQL Server -> General and check the “By default, open new queries in SQLCMD mode” checkbox:

这将打开“ 选项”窗口。 从列表中,选择查询执行-> SQL Server->常规,然后选中“默认情况下,以SQLCMD模式打开新查询”复选框:

When using SQLCMD mode the IntelliSense and Transact-SQL debugger are turned off in the Database Engine Query Editor.

使用SQLCMD模式时,在数据库引擎查询编辑器中将关闭IntelliSense和Transact-SQL 调试器。

In the SQLCMD mode, two types of statement can be entered: the first are the SQLCMD and second are T-SQL statements.

在SQLCMD模式下,可以输入两种类型的语句:第一种是SQLCMD,第二种是T-SQL语句。

In the example below, some of the SQLCMD script keywords will be explained:

在下面的示例中,将解释一些SQLCMD脚本关键字:

 :CONNECT ZIVKO\ZIVKO2014 :OUT C:\Users\Marko\Data.txt

:CONNECT ZIVKO \ ZIVKO2014 :OUT C:\ Users \ Marko \ Data.txt

 USE AdventureWorks2014;  SELECT a.City, a.PostalCode  FROM Person.Address a

使用 AdventureWorks2014; 个人中选择 a.City,a.PostalCode。 地址 a

When executing the code, the result in the query editor will be:

执行代码时,查询编辑器中的结果将是:

The SQLCMD commands are automatically highlighted in gray and the T-SQL statements appear normal as it appears in the regular query.

SQLCMD命令将自动以灰色突出显示,并且T-SQL语句显示为常规查询中的正常状态。

Most of the SQLCMD commands begin with a colon (:). For a few SQLCMD commands, such as QUIT and EXIT though, a colon (:) can be omitted.

大多数SQLCMD命令以冒号(:)开头。 对于一些SQLCMD命令,例如QUIT和EXIT,可以省略冒号(:)。

For example, the quit command will work the same as the command : quit.

例如, quit命令将与命令quit相同。

This is enabled because of backward compatibility with the osql utility.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值