Skip to content

Commit 3a69fbe

Browse files
committed
[SCOPED] Fix Transact-SQL in code blocks
1 parent b962700 commit 3a69fbe

37 files changed

Lines changed: 1611 additions & 1410 deletions

File tree

docs/connect/odbc/linux-mac/connecting-with-sqlcmd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ You can use the following alternative method: Put the parameters inside one file
229229
Then create a file called `b.sql`, with the parameters for replacement:
230230

231231
```sql
232-
select $(ColumnName) from $(TableName)
232+
SELECT $(ColumnName) FROM $(TableName)
233233
```
234234

235235
At the command line, combine `a.sql` and `b.sql` into `c.sql` using the following commands:

docs/database-engine/service-broker/handling-service-broker-error-messages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Use the WITH ERROR clause of the END CONVERSATION statement to report applicatio
2828

2929
```sql
3030
END CONVERSATION @ConversationHandle
31-
WITH ERROR = 1234 DESCRIPTION = "The account specified in the invoice does not exist, verify the account number."
31+
WITH ERROR = 1234 DESCRIPTION = 'The account specified in the invoice does not exist, verify the account number.';
3232
```
3333

3434
The END CONVERSATION WITH ERROR statement:

docs/database-engine/service-broker/service-broker-application-outline.md

Lines changed: 64 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -52,92 +52,82 @@ For simplicity, the script produces a result set for each message. If an error o
5252
[!INCLUDE [SQL Server Service Broker AdventureWorks2008R2](../../includes/service-broker-adventureworks-2008-r2.md)]
5353

5454
```sql
55-
USE AdventureWorks2008R2 ;
56-
GO
55+
USE [AdventureWorks2022];
56+
GO
5757

58-
-- Process all conversation groups.
59-
60-
WHILE (1 = 1)
58+
-- Process all conversation groups.
59+
WHILE (1 = 1)
6160
BEGIN
62-
63-
DECLARE @conversation_handle UNIQUEIDENTIFIER,
61+
DECLARE
62+
@conversation_handle UNIQUEIDENTIFIER,
6463
@conversation_group_id UNIQUEIDENTIFIER,
6564
@message_body XML,
6665
@message_type_name NVARCHAR(128);
6766

67+
-- Begin a transaction, one per conversation group.
68+
BEGIN TRANSACTION;
6869

69-
-- Begin a transaction, one per conversation group.
70-
71-
BEGIN TRANSACTION ;
72-
73-
-- Get next conversation group.
70+
-- Get next conversation group.
71+
WAITFOR (
72+
GET CONVERSATION GROUP @conversation_group_id
73+
FROM [MyServiceQueue]
74+
),
75+
TIMEOUT 500;
7476

75-
WAITFOR(
76-
GET CONVERSATION GROUP @conversation_group_id FROM MyServiceQueue),
77-
TIMEOUT 500 ;
77+
-- Restore the state for this conversation group here
78+
-- If there are no more conversation groups, break.
79+
IF @conversation_group_id IS NULL
80+
BEGIN
81+
ROLLBACK TRANSACTION;
7882

79-
-- Restore the state for this conversation group here
80-
81-
-- If there are no more conversation groups, break.
82-
83-
IF @conversation_group_id IS NULL
84-
BEGIN
85-
ROLLBACK TRANSACTION ;
86-
BREAK ;
87-
END ;
83+
BREAK;
84+
END;
8885

8986
-- Process all messages in the conversation group.
90-
9187
WHILE 1 = 1
92-
BEGIN
93-
94-
-- Get the next message.
95-
96-
RECEIVE
97-
TOP(1)
98-
@conversation_handle = conversation_handle,
99-
@message_type_name = message_type_name,
100-
@message_body =
101-
CASE
102-
WHEN validation = 'X' THEN CAST(message_body AS XML)
103-
ELSE CAST(N'<none/>' AS XML)
104-
END
105-
FROM MyServiceQueue
106-
WHERE conversation_group_id = @conversation_group_id;
107-
108-
-- If there is no message, or there is an error
109-
-- reading from the queue, break.
110-
111-
IF @@ROWCOUNT = 0 OR @@ERROR <> 0
112-
BREAK;
113-
114-
-- Process the message. In this case, the program ends the conversation
115-
-- for Error and EndDialog messages. For all other messages, the program
116-
-- produces a result set with information about the message.
117-
118-
SELECT @conversation_handle,
119-
@message_type_name,
120-
@message_body ;
121-
122-
-- If the message is an end dialog message or an error,
123-
-- end the conversation. Notice that other conversations
124-
-- in the same conversation group may still have messages
125-
-- to process. Therefore, the program does not break after
126-
-- ending the conversation.
127-
128-
IF @message_type_name =
129-
'https://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
130-
OR @message_type_name =
131-
'https://schemas.microsoft.com/SQL/ServiceBroker/Error'
132-
BEGIN
133-
END CONVERSATION @conversation_handle ;
134-
END ;
135-
136-
END ; -- Process all messages in conversation group.
137-
138-
COMMIT TRANSACTION ;
139-
140-
END ; -- Process all conversation groups.
88+
BEGIN
89+
-- Get the next message.
90+
RECEIVE TOP (1)
91+
@conversation_handle = [conversation_handle],
92+
@message_type_name = [message_type_name],
93+
@message_body = CASE
94+
WHEN [validation] = 'X'
95+
THEN
96+
CAST([message_body] AS XML)
97+
ELSE
98+
CAST(N'<none/>' AS XML)
99+
END
100+
FROM [MyServiceQueue]
101+
WHERE CONVERSATION_GROUP_ID = @conversation_group_id;
102+
103+
-- If there is no message, or there is an error
104+
-- reading from the queue, break.
105+
IF @@ROWCOUNT = 0
106+
OR @@ERROR <> 0
107+
BREAK;
108+
109+
-- Process the message. In this case, the program ends the conversation
110+
-- for Error and EndDialog messages. For all other messages, the program
111+
-- produces a result set with information about the message.
112+
SELECT
113+
@conversation_handle,
114+
@message_type_name,
115+
@message_body;
116+
117+
-- If the message is an end dialog message or an error,
118+
-- end the conversation. Notice that other conversations
119+
-- in the same conversation group may still have messages
120+
-- to process. Therefore, the program does not break after
121+
-- ending the conversation.
122+
IF @message_type_name = 'https://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
123+
OR @message_type_name = 'https://schemas.microsoft.com/SQL/ServiceBroker/Error'
124+
BEGIN
125+
END CONVERSATION @conversation_handle;
126+
END;
127+
END; -- Process all messages in conversation group.
128+
129+
COMMIT TRANSACTION;
130+
END; -- Process all conversation groups.
141131
```
142132

143133
## See also

docs/integration-services/extending-packages-scripting-data-flow-script-component-types/creating-a-synchronous-transformation-with-the-script-component.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,11 @@ public class ScriptMain:
205205
7. Create and configure two destination components that expect the **AddressID** and **City** columns, such as a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] destination, a Flat File destination, or the sample destination component demonstrated in [Creating a Destination with the Script Component](../../integration-services/extending-packages-scripting-data-flow-script-component-types/creating-a-destination-with-the-script-component.md). Then connect each of the outputs of the transformation to one of the destination components. You can create destination tables by running a [!INCLUDE[tsql](../../includes/tsql-md.md)] command similar to the following (with unique table names) in the **AdventureWorks** database:
206206

207207
```sql
208-
CREATE TABLE [Person].[Address2](
209-
[AddressID] [int] NOT NULL,
210-
[City] [nvarchar](30) NOT NULL
211-
```
208+
CREATE TABLE [Person].[Address2] (
209+
[AddressID] INT NOT NULL,
210+
[City] NVARCHAR(30) NOT NULL
211+
);
212+
```
212213

213214
8. Run the sample.
214215

docs/linux/sql-server-linux-create-availability-group.md

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -459,27 +459,42 @@ This example shows the creation of a two-replica configuration using a cluster t
459459

460460
1. Execute on the node that will be the primary replica containing the fully read/write copy of the databases. This example uses automatic seeding.
461461

462-
```sql
463-
CREATE AVAILABILITY GROUP [<AGName>]
464-
WITH (CLUSTER_TYPE = NONE)
465-
FOR DATABASE <DBName>
466-
REPLICA ON N'LinAGN1'
467-
WITH (
468-
ENDPOINT_URL = N'TCP://LinAGN1.FullyQualified.Name: <PortOfEndpoint>',
469-
FAILOVER_MODE = MANUAL,
470-
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,
471-
PRIMARY_ROLE (ALLOW_CONNECTIONS = READ_WRITE, READ_ONLY_ROUTING_LIST = (('LinAGN1.FullyQualified.Name'.'LinAGN2.FullyQualified.Name'))),
472-
SECONDARY_ROLE (ALLOW_CONNECTIONS = ALL, READ_ONLY_ROUTING_URL = N'TCP://LinAGN1.FullyQualified.Name:<PortOfInstance>'));
473-
N'LinAGN2' WITH (
474-
ENDPOINT_URL = N'TCP://LinAGN2.FullyQualified.Name:<PortOfEndpoint>',
475-
FAILOVER_MODE = MANUAL,
476-
SEEDING_MODE = AUTOMATIC,
477-
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,
478-
PRIMARY_ROLE (ALLOW_CONNECTIONS = READ_WRITE, READ_ONLY_ROUTING_LIST = (('LinAGN1.FullyQualified.Name', 'LinAGN2.FullyQualified.Name'))),
479-
SECONDARY_ROLE (ALLOW_CONNECTIONS = ALL, READ_ONLY_ROUTING_URL =N'TCP://LinAGN2.FullyQualified.Name:<PortOfInstance>'));
480-
LISTENER '<ListenerName>' (WITH IP = ('<PrimaryReplicaIPAddress>', '<SubnetMask>'), Port = <PortOfListener>);
481-
GO
482-
```
462+
```sql
463+
CREATE AVAILABILITY
464+
GROUP [<AGName>]
465+
WITH (CLUSTER_TYPE = NONE)
466+
FOR DATABASE <DBName> REPLICA ON
467+
N'LinAGN1' WITH (
468+
ENDPOINT_URL = N'TCP://LinAGN1.FullyQualified.Name: <PortOfEndpoint>',
469+
FAILOVER_MODE = MANUAL,
470+
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,
471+
PRIMARY_ROLE(
472+
ALLOW_CONNECTIONS = READ_WRITE,
473+
READ_ONLY_ROUTING_LIST = (('LinAGN1.FullyQualified.Name'.'LinAGN2.FullyQualified.Name'))
474+
),
475+
SECONDARY_ROLE(
476+
ALLOW_CONNECTIONS = ALL,
477+
READ_ONLY_ROUTING_URL = N'TCP://LinAGN1.FullyQualified.Name:<PortOfInstance>'
478+
)
479+
),
480+
N'LinAGN2' WITH (
481+
ENDPOINT_URL = N'TCP://LinAGN2.FullyQualified.Name:<PortOfEndpoint>',
482+
FAILOVER_MODE = MANUAL,
483+
SEEDING_MODE = AUTOMATIC,
484+
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,
485+
PRIMARY_ROLE(ALLOW_CONNECTIONS = READ_WRITE, READ_ONLY_ROUTING_LIST = (
486+
('LinAGN1.FullyQualified.Name',
487+
'LinAGN2.FullyQualified.Name')
488+
)),
489+
SECONDARY_ROLE(ALLOW_CONNECTIONS = ALL, READ_ONLY_ROUTING_URL = N'TCP://LinAGN2.FullyQualified.Name:<PortOfInstance>')
490+
),
491+
LISTENER '<ListenerName>' (WITH IP = (
492+
'<PrimaryReplicaIPAddress>',
493+
'<SubnetMask>'),
494+
Port = <PortOfListener>
495+
);
496+
GO
497+
```
483498

484499
Where:
485500

docs/machine-learning/tutorials/quickstart-r-data-types-and-objects.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ Now, review the text in **Messages** to see why the output is different.
115115

116116
**Results - Example 1**
117117

118-
```sql
118+
```output
119119
STDOUT message(s) from external script:
120120
'data.frame': 3 obs. of 1 variable:
121121
$ mytextvariable: Factor w/ 3 levels " ","hello","world": 2 1 3
122122
```
123123

124124
**Results - Example 2**
125125

126-
```sql
126+
```output
127127
STDOUT message(s) from external script:
128128
'data.frame': 1 obs. of 3 variables:
129129
$ c..hello..: Factor w/ 1 level "hello": 1

docs/relational-databases/backup-restore/restart-an-interrupted-restore-operation-transact-sql.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ This example restarts an interrupted restore operation, using the example `Adven
4242
```sql
4343
-- Restore a full database backup of the AdventureWorks database.
4444
RESTORE DATABASE AdventureWorks2022
45-
FROM DISK = 'C:\Temp\AdventureWorks2022.bak';
45+
FROM DISK = 'C:\Temp\AdventureWorks2022.bak';
4646
GO
47+
4748
-- The restore operation halted prematurely.
4849
-- Repeat the original RESTORE statement specifying WITH RESTART.
4950
RESTORE DATABASE AdventureWorks2022
50-
FROM DISK = 'C:\Temp\AdventureWorks2022.bak';
51-
WITH RESTART;
51+
FROM DISK = 'C:\Temp\AdventureWorks2022.bak'
52+
WITH RESTART;
5253
GO
5354
```
5455

docs/relational-databases/backup-restore/sql-server-backup-to-url-s3-compatible-object-storage.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,13 @@ If no value is declared, `us-east-1` is assigned as default.
181181
Backup example:
182182

183183
```sql
184-
WITH
185-
BACKUP_OPTIONS = '{"s3": {"region":"us-west-1"}}'
184+
WITH BACKUP_OPTIONS = '{"s3": {"region":"us-west-1"}}'
186185
```
187186

188187
Restore example:
189188

190189
```sql
191-
WITH
192-
RESTORE_OPTIONS = '{"s3": {"region":"us-west-1"}}'
190+
WITH RESTORE_OPTIONS = '{"s3": {"region":"us-west-1"}}'
193191
```
194192

195193
### Linux support

0 commit comments

Comments
 (0)