Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 9bd741c

Browse files
authored
Merge pull request #20693 from MicrosoftDocs/master
11/18 AM Publish
2 parents cb9fbd0 + c960066 commit 9bd741c

2 files changed

Lines changed: 88 additions & 27 deletions

File tree

docs/linux/sql-server-linux-configure-mssql-conf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ The following options configure TLS for an instance of SQL Server running on Lin
650650
|**network.tlscert** |The absolute path to the certificate file that [!INCLUDE[ssNoVersion](../includes/ssnoversion-md.md)] uses for TLS. Example: `/etc/ssl/certs/mssql.pem` The certificate file must be accessible by the mssql account. Microsoft recommends restricting access to the file using `chown mssql:mssql <file>; chmod 400 <file>`. |
651651
|**network.tlskey** |The absolute path to the private key file that [!INCLUDE[ssNoVersion](../includes/ssnoversion-md.md)] uses for TLS. Example: `/etc/ssl/private/mssql.key` The certificate file must be accessible by the mssql account. Microsoft recommends restricting access to the file using `chown mssql:mssql <file>; chmod 400 <file>`. |
652652
|**network.tlsprotocols** |A comma-separated list of which TLS protocols are allowed by SQL Server. [!INCLUDE[ssNoVersion](../includes/ssnoversion-md.md)] always attempts to negotiate the strongest allowed protocol. If a client does not support any allowed protocol, [!INCLUDE[ssNoVersion](../includes/ssnoversion-md.md)] rejects the connection attempt. For compatibility, all supported protocols are allowed by default (1.2, 1.1, 1.0). If your clients support TLS 1.2, Microsoft recommends allowing only TLS 1.2. |
653-
|**network.tlsciphers** |Specifies which ciphers are allowed by [!INCLUDE[ssNoVersion](../includes/ssnoversion-md.md)] for TLS. This string must be formatted per [OpenSSL's cipher list format](https://www.openssl.org/docs/man1.0.2/apps/ciphers.html). In general, you should not need to change this option. <br /> By default, the following ciphers are allowed: <br /> `ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA` |
653+
|**network.tlsciphers** |Specifies which ciphers are allowed by [!INCLUDE[ssNoVersion](../includes/ssnoversion-md.md)] for TLS. This string must be formatted per [OpenSSL's cipher list format](https://www.openssl.org/docs/manmaster/man1/ciphers.html). In general, you should not need to change this option. <br /> By default, the following ciphers are allowed: <br /> `ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA` |
654654
| **network.kerberoskeytabfile** |Path to the Kerberos keytab file |
655655
656656
For an example of using the TLS settings, see [Encrypting Connections to SQL Server on Linux](sql-server-linux-encrypted-connections.md).

docs/t-sql/language-elements/select-local-variable-transact-sql.md

Lines changed: 87 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: "SELECT @local_variable (Transact-SQL)"
33
title: SELECT @local_variable (Transact-SQL)
44
ms.custom: ""
5-
ms.date: "09/06/2017"
5+
ms.date: "11/11/2021"
66
ms.prod: sql
77
ms.prod_service: "database-engine, sql-database"
88
ms.reviewer: ""
@@ -22,7 +22,6 @@ helpviewer_keywords:
2222
- "SELECT statement [SQL Server], @local_variable"
2323
- "@local_variable"
2424
- "local variables [SQL Server]"
25-
ms.assetid: 8e1a9387-2c5d-4e51-a1fd-a2a95f026d6f
2625
author: cawrites
2726
ms.author: chadam
2827
monikerRange: "= azuresqldb-current ||>= sql-server-2016 ||= azure-sqldw-latest||>= sql-server-linux-2017"
@@ -49,15 +48,15 @@ SELECT { @local_variable { = | += | -= | *= | /= | %= | &= | ^= | |= } expressio
4948

5049
## Arguments
5150

52-
@*local_variable*
51+
#### @*local_variable*
5352
Is a declared variable for which a value is to be assigned.
5453

5554
{= \| += \| -= \| \*= \| /= \| %= \| &= \| ^= \| \|= }
5655
Assign the value on the right to the variable on the left.
5756

5857
Compound assignment operator:
5958

60-
| operator | action |
59+
| **operator** | **action** |
6160
| -------- | ------ |
6261
| = | Assigns the expression that follows, to the variable. |
6362
| += | Add and assign |
@@ -69,7 +68,7 @@ Compound assignment operator:
6968
| ^= | Bitwise XOR and assign |
7069
| \|= | Bitwise OR and assign |
7170

72-
*expression*
71+
#### *expression*
7372
Is any valid [expression](../../t-sql/language-elements/expressions-transact-sql.md). This includes a scalar subquery.
7473

7574
## Remarks
@@ -82,21 +81,24 @@ One SELECT statement can initialize multiple local variables.
8281

8382
> [!NOTE]
8483
> A SELECT statement that contains a variable assignment cannot be used to also perform typical result set retrieval operations.
85-
84+
8685
## Examples
8786

87+
88+
8889
### A. Use SELECT @local_variable to return a single value
89-
In the following example, the variable `@var1` is assigned `Generic Name` as its value. The query against the `Store` table returns no rows because the value specified for `CustomerID` does not exist in the table. The variable retains the `Generic Name` value.
90+
In the following example, the variable `@var1` is assigned "Generic Name" as its value. The query against the `Store` table returns no rows because the value specified for `CustomerID` does not exist in the table. The variable retains the "Generic Name" value.
91+
92+
This example uses the AdventureWorks2019LT sample database, for more information, see [AdventureWorks sample databases](../../samples/adventureworks-install-configure.md). The AdventureWorksLT database is used as the `sample` database for [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)].
9093

9194
```sql
92-
-- Uses AdventureWorks
93-
95+
-- Uses AdventureWorks2019LT
9496
DECLARE @var1 VARCHAR(30);
9597
SELECT @var1 = 'Generic Name';
96-
SELECT @var1 = Name
97-
FROM Sales.Store
98-
WHERE CustomerID = 1000 ;
99-
SELECT @var1 AS 'Company Name';
98+
SELECT @var1 = [Name]
99+
FROM SalesLT.Product
100+
WHERE ProductID = 1000000; --Value does not exist
101+
SELECT @var1 AS 'ProductName';
100102
```
101103

102104
[!INCLUDE[ssResult](../../includes/ssresult-md.md)]
@@ -109,16 +111,19 @@ SELECT @var1 AS 'Company Name';
109111

110112
### B. Use SELECT @local_variable to return null
111113
In the following example, a subquery is used to assign a value to `@var1`. Because the value requested for `CustomerID` does not exist, the subquery returns no value and the variable is set to `NULL`.
114+
115+
This example uses the AdventureWorks2019LT sample database, for more information, see [AdventureWorks sample databases](../../samples/adventureworks-install-configure.md). The AdventureWorksLT database is used as the `sample` database for [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)].
112116

113117
```sql
114-
-- Uses AdventureWorks
115-
116-
DECLARE @var1 VARCHAR(30)
117-
SELECT @var1 = 'Generic Name'
118-
SELECT @var1 = (SELECT Name
119-
FROM Sales.Store
120-
WHERE CustomerID = 1000)
121-
SELECT @var1 AS 'Company Name' ;
118+
-- Uses AdventureWorks2019
119+
DECLARE @var1 VARCHAR(30);
120+
SELECT @var1 = 'Generic Name';
121+
122+
SELECT @var1 = (SELECT [Name]
123+
FROM SalesLT.Product
124+
WHERE ProductID = 1000000); --Value does not exist
125+
126+
SELECT @var1 AS 'Company Name';
122127
```
123128

124129
[!INCLUDE[ssResult](../../includes/ssresult-md.md)]
@@ -128,9 +133,65 @@ Company Name
128133
----------------------------
129134
NULL
130135
```
136+
137+
### C. Antipattern use of recursive variable assignment
138+
139+
Avoid the following pattern for recursive use of variables and expressions:
140+
141+
```sqlsyntax
142+
SELECT @Var = <expression containing @Var>
143+
FROM
144+
...
145+
```
146+
147+
In this case, it is not guaranteed that `@Var` would be updated on a row by row basis. For example, `@Var` may be set to initial value of `@Var` for all rows. This is because the order and frequency in which the assignments are processed is nondeterminant. This applies to expressions containing variables string concatenation, as demonstrated below, but also to expressions with non-string variables or += style operators. Use aggregation functions instead for a set-based operation instead of a row-by-row operation.
148+
149+
For string concatenation, instead consider the `STRING_AGG` function, introduced in [!INCLUDE[sssql17-md](../../includes/sssql17-md.md)], for scenarios where ordered string concatenation is desired. For more information, see [STRING_AGG (Transact-SQL)](../functions/string-agg-transact-sql.md). This example uses the AdventureWorks2016 or AdventureWorks2019 sample database. For more information, see [AdventureWorks sample databases](../../samples/adventureworks-install-configure.md).
150+
151+
An example to avoid, where using ORDER BY in attempt to order concatenation causes list to be incomplete:
152+
153+
```sql
154+
DECLARE @List AS nvarchar(max);
155+
SELECT @List = CONCAT(COALESCE(@List + ', ',''), p.LastName)
156+
FROM Person.Person AS p
157+
WHERE p.FirstName = 'William'
158+
ORDER BY p.BusinessEntityID;
159+
SELECT @List;
160+
```
161+
162+
Result set:
163+
164+
```
165+
(No column name)
166+
---
167+
Walker
168+
```
169+
170+
Instead, consider:
171+
172+
```sql
173+
DECLARE @List AS nvarchar(max);
174+
SELECT @List = STRING_AGG(p.LastName,', ') WITHIN GROUP (ORDER BY p.BusinessEntityID)
175+
FROM Person.Person AS p
176+
WHERE p.FirstName = 'William';
177+
SELECT @List;
178+
```
179+
180+
Result set:
181+
182+
```
183+
(No column name)
184+
---
185+
Vong, Conner, Hapke, Monroe, Richter, Sotelo, Vong, Ngoh, White, Harris, Martin, Thompson, Martinez, Robinson, Clark, Rodriguez, Smith, Johnson, Williams, Jones, Brown, Davis, Miller, Moore, Taylor, Anderson, Thomas, Lewis, Lee, Walker
186+
```
131187

132-
## See Also
133-
[DECLARE @local_variable &#40;Transact-SQL&#41;](../../t-sql/language-elements/declare-local-variable-transact-sql.md)
134-
[Expressions &#40;Transact-SQL&#41;](../../t-sql/language-elements/expressions-transact-sql.md)
135-
[Compound Operators &#40;Transact-SQL&#41;](../../t-sql/language-elements/compound-operators-transact-sql.md)
136-
[SELECT &#40;Transact-SQL&#41;](../../t-sql/queries/select-transact-sql.md)
188+
## See also
189+
190+
- [DECLARE @local_variable &#40;Transact-SQL&#41;](../../t-sql/language-elements/declare-local-variable-transact-sql.md)
191+
- [Expressions &#40;Transact-SQL&#41;](../../t-sql/language-elements/expressions-transact-sql.md)
192+
- [Compound Operators &#40;Transact-SQL&#41;](../../t-sql/language-elements/compound-operators-transact-sql.md)
193+
- [SELECT &#40;Transact-SQL&#41;](../../t-sql/queries/select-transact-sql.md)
194+
195+
## Next steps
196+
197+
- [AdventureWorks sample databases](../../samples/adventureworks-install-configure.md)

0 commit comments

Comments
 (0)