Skip to content

Commit 80b93ac

Browse files
committed
reviewr editor
1 parent 8676385 commit 80b93ac

10 files changed

Lines changed: 138 additions & 135 deletions

‎.openpublishing.redirection.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59487,12 +59487,12 @@
5948759487
},
5948859488
{
5948959489
"source_path": "docs/ssms/scripting/sqlcmd-start-the-utility.md",
59490-
"redirect_url": "/sql/tools/sqlcmd/sqlcmd-start-the-utility",
59490+
"redirect_url": "/sql/tools/sqlcmd/sqlcmd-start-utility",
5949159491
"redirect_document_id": true
5949259492
},
5949359493
{
5949459494
"source_path": "docs/ssms/scripting/sqlcmd-connect-to-the-database-engine.md",
59495-
"redirect_url": "/sql/tools/sqlcmd/sqlcmd-connect-to-the-database-engine",
59495+
"redirect_url": "/sql/tools/sqlcmd/sqlcmd-connect-database-engine",
5949659496
"redirect_document_id": true
5949759497
},
5949859498
{
@@ -59502,7 +59502,7 @@
5950259502
},
5950359503
{
5950459504
"source_path": "docs/ssms/scripting/sqlcmd-use-the-utility.md",
59505-
"redirect_url": "/sql/tools/sqlcmd/sqlcmd-use-the-utility",
59505+
"redirect_url": "/sql/tools/sqlcmd/sqlcmd-use-utility",
5950659506
"redirect_document_id": true
5950759507
},
5950859508
{

‎docs/toc.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8410,6 +8410,8 @@ items:
84108410
href: tools/sqlcmd/sqlcmd-run-transact-sql-script-files.md
84118411
- name: Use with Scripting Variables
84128412
href: tools/sqlcmd/sqlcmd-use-with-scripting-variables.md
8413+
- name: Edit SQLCMD Scripts with Query Editor
8414+
href: tools/sqlcmd/edit-sqlcmd-scripts-with-query-editor.md
84138415
- name: SSB Diagnose
84148416
href: tools/ssbdiagnose/ssbdiagnose-utility-service-broker.md
84158417
items:
@@ -9263,8 +9265,6 @@ items:
92639265
href: ssms/scripting/manage-code-formatting.md
92649266
- name: Navigate Code & Text
92659267
href: ssms/scripting/navigate-code-and-text.md
9266-
- name: Edit SQLCMD Scripts with Query Editor
9267-
href: ssms/scripting/edit-sqlcmd-scripts-with-query-editor.md
92689268
- name: References
92699269
items:
92709270
- name: SQL Server Management Objects (SMO)

‎docs/tools/sqlcmd/edit-sqlcmd-scripts-with-query-editor.md‎

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Edit SQLCMD Scripts with Query Editor"
2+
title: Sqlcmd utility - Edit SQLCMD scripts with Query Editor
33
description: You use SQLCMD scripts when you have to process Windows System commands and Transact-SQL statements in the same script. Learn how to write and edit SQLCMD scripts using the Database Engine Query Editor.
44
author: grrlgeek
55
ms.author: jeschult
@@ -17,16 +17,15 @@ helpviewer_keywords:
1717
- "scripts [SQL Server], SQL Server Management Studio"
1818
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
1919
---
20-
2120
# Edit SQLCMD Scripts with Query Editor
2221

2322
[!INCLUDE[SQL Server Azure SQL Database Synapse Analytics PDW](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)]
2423

25-
By using the Database Engine Query Editor in SQL Server Management Studio you can write and edit queries as SQLCMD scripts. You use SQLCMD scripts when you have to process Windows System commands and Transact\-SQL statements in the same script.
24+
Using the Database Engine Query Editor in SQL Server Management Studio, you can write and edit queries as SQLCMD scripts. You use SQLCMD scripts when processing Windows System commands and Transact\-SQL statements in the same script.
2625

2726
## SQLCMD Mode
2827

29-
To use the Database Engine Query Editor to write or edit SQLCMD scripts, you must enable the SQLCMD scripting mode. By default, SQLCMD mode is not enabled in the Query Editor. You can enable scripting mode by selecting the **SQLCMD Mode** icon in the toolbar or by selecting **SQLCMD Mode** from the **Query** menu.
28+
To use the Database Engine Query Editor to write or edit SQLCMD scripts, you must enable the SQLCMD scripting mode. By default, SQLCMD mode isn't allowed in the Query Editor. You can enable scripting mode by selecting the **SQLCMD Mode** icon in the toolbar or by selecting **SQLCMD Mode** from the **Query** menu.
3029

3130
> [!NOTE]
3231
> Enabling SQLCMD mode turns off IntelliSense and the Transact\-SQL debugger in the Database Engine Query Editor.
@@ -49,7 +48,7 @@ SQLCMD scripts in the Query Editor can use the same features that all Transact\-
4948

5049
#### Switch a database engine query editor window to sqlcmd mode
5150

52-
1. In Object Explorer, right-click the server, and then select **New Query**, to open a new Database Engine Query Editor window.
51+
1. In Object Explorer, right-click the server and then select **New Query**, to open a new Database Engine Query Editor window.
5352

5453
1. On the **Query** menu, select **SQLCMD Mode**.
5554

@@ -68,7 +67,7 @@ SQLCMD scripts in the Query Editor can use the same features that all Transact\-
6867
GO
6968
```
7069

71-
1. Press F5 to execute the whole section of mixed Transact\-SQL and MS-DOS statements.
70+
1. Press F5 to execute the mixed Transact\-SQL and MS-DOS statements section.
7271

7372
Notice the two SQL result panes from the first and third statements.
7473

@@ -83,36 +82,36 @@ SQLCMD scripts in the Query Editor can use the same features that all Transact\-
8382
> [!IMPORTANT]
8483
> When executed from the command line, the **sqlcmd** utility permits full interaction with the operating system. When you use the Query Editor in **SQLCMD Mode**, you must be careful not to execute interactive statements. The Query Editor cannot respond to operating system prompts.
8584

86-
For more information about how to run SQLCMD, see [sqlcmd Utility](../../tools/sqlcmd-utility.md), or take the SQLCMD tutorial.
85+
For more information about how to run SQLCMD, see [Sqlcmd utility](../../tools/sqlcmd-utility.md), or take the SQLCMD tutorial.
8786

8887
## Enable SQLCMD Scripting by Default
8988

90-
To turn SQLCMD scripting on by default, on the **Tools** menu select **Options**, expand **Query Execution**, and **SQL Server**, select the **General** page, and then check the **By default open new queries in SQLCMD Mode** box.
89+
To turn on SQLCMD scripting by default, on the **Tools** menu, select **Options**, expand **Query Execution**, and **SQL Server**, select the **General** page and then check the **By default open new queries in SQLCMD Mode** box.
9190

9291
## Write and Editing SQLCMD Scripts
9392

94-
After enabling scripting mode you may write SQLCMD commands and Transact\-SQL statements. The following rules apply:
93+
After enabling scripting mode, you may write SQLCMD commands and Transact\-SQL statements. The following rules apply:
9594

9695
- SQLCMD commands must be the first statement on a line.
9796

9897
- Only one SQLCMD command is permitted on each line.
9998

10099
- SQLCMD commands can be preceded by comments or white space.
101100

102-
- SQLCMD commands within comment characters are not executed.
101+
- SQLCMD commands within comment characters aren't executed.
103102
104-
- Single line comment characters are two hyphens (`--)` and must appear at the beginning of a line.
103+
- Single-line comment characters are two hyphens (`--)` and must appear at the beginning of a line.
105104
106105
- Operating system commands must be preceded by two exclamation points (`!!`). The double-exclamation points command causes the statement that follows the exclamation points to be executed using the `cmd.exe` command processor. The text after `!!` is passed in as a parameter to `cmd.exe`, so the final command line will execute as: `"%SystemRoot%\system32\cmd.exe /c <text after !!>"`.
107106
108-
- To make a clear distinction between SQLCMD commands and Transact\-SQL, all SQLCMD commands, need to be prefixed with a colon (`:`).
107+
- To make a clear distinction between SQLCMD commands and Transact\-SQL, all SQLCMD commands need to be prefixed with a colon (`:`).
109108
110-
- The `GO` command may be used without preface, or preceded by `!!:`
109+
- The `GO` command may be used without preface or preceded by `!!:`
111110
112-
- The Database Engine Query Editor supports environment variables and variables that are defined as part of a SQLCMD script, but does not support built-in SQLCMD or **osql** variables. SQLCMD processing by SQL Server Management Studio is case sensitive for variables. For example, PRINT '$(COMPUTERNAME)' produces the correct result, but PRINT '$(ComputerName)' returns an error.
111+
- The Database Engine Query Editor supports environment variables and variables that are defined as part of a SQLCMD script, but doesn't support built-in SQLCMD or **osql** variables. SQLCMD processing by SQL Server Management Studio is case sensitive for variables. For example, PRINT '$(COMPUTERNAME)' produces the correct result, but PRINT '$(ComputerName)' returns an error.
113112

114113
> [!CAUTION]
115-
> SQL Server Management Studio uses [!INCLUDE[msCoName](../../includes/msconame-md.md)] [!INCLUDE[dnprdnshort](../../includes/dnprdnshort-md.md)]SqlClient for execution in regular and SQLCMD mode. When run from the command line, SQLCMD uses the OLE DB provider. Because different default options may apply, it is possible to get different behavior while executing the same query in SQL Server Management Studio SQLCMD Mode, and in the SQLCMD utility.
114+
> SQL Server Management Studio uses [!INCLUDE[msCoName](../../includes/msconame-md.md)] [!INCLUDE[dnprdnshort](../../includes/dnprdnshort-md.md)]SqlClient for execution in regular and SQLCMD mode. When run from the command line, SQLCMD uses the OLE DB provider. Because different default options may apply, it is possible to get different behavior while executing the same query in SQL Server Management Studio SQLCMD Mode and in the SQLCMD utility.
116115

117116
## Supported SQLCMD Syntax
118117

@@ -139,20 +138,20 @@ SQLCMD scripts in the Query Editor can use the same features that all Transact\-
139138
`:out <filename>|stderr|stdout`
140139

141140
> [!NOTE]
142-
> For both `:error` and `:out`, `stderr` and `stdout` send output to the messages tab.
141+
> Send output to the messages tab for both `:error` and `:out`, `stderr` and `stdout`.
143142

144-
SQLCMD commands not listed above are not supported in Query Editor. When a script containing SQLCMD keywords that are not supported is executed, the Query Editor will send an "Ignoring command *\<ignored command*>" message to the destination for each unsupported keyword. The script will execute successfully, but the unsupported commands will be ignored.
143+
SQLCMD commands not listed above aren't supported in Query Editor. When a script containing SQLCMD keywords aren't supported is executed, the Query Editor will send an "Ignoring command *\<ignored command*>" message to the destination for each unsupported keyword. The script will execute successfully, but the unsupported commands will be ignored.
145144

146145
> [!CAUTION]
147-
> Because you are not starting SQLCMD from the command line, there are some limitations when running Query Editor in SQLCMD Mode. You cannot pass in command-line parameters such as variables, and, because the Query Editor does not have the ability to respond to operating system prompts, you must be careful not to execute interactive statements.
146+
> Because you are not starting SQLCMD from the command line, there are some limitations when running Query Editor in SQLCMD Mode. You cannot pass in command-line parameters such as variables, and, because the Query Editor cannot respond to operating system prompts, you must be careful not to execute interactive statements.
148147

149148
## Color Coding in SQLCMD Scripts
150149

151150
With SQLCMD scripting enabled, scripts will be color coded. The color coding for Transact\-SQL keywords will remain the same. SQLCMD commands are presented with a shaded background.
152151

153152
## Example
154153

155-
The following example uses a **sqlcmd** statement to create an output file called testoutput.txt, executes two Transact\-SQL SELECT statements along with one operating system command (to print out the current directory). The resultant file contains the message output from the `DIR` statement, followed by the results output from the Transact\-SQL statements.
154+
The following example uses a **sqlcmd** statement to create an output file called testoutput.txt, executes two Transact\-SQL SELECT statements along with one operating system command (to print the current directory). The resultant file contains the message output from the `DIR` statement and the results output from the Transact\-SQL statements.
156155

157156
```bash
158157
:out C:\testoutput.txt
@@ -163,6 +162,6 @@ SELECT @@SERVERNAME AS 'Server Name'
163162
GO
164163
```
165164

166-
## Nest steps
165+
## Next steps
167166

168-
- [sqlcmd Utility](../../tools/sqlcmd-utility.md)
167+
- [Sqlcmd utility](sqlcmd-utility.md)

0 commit comments

Comments
 (0)