Skip to content

Commit 26ff836

Browse files
committed
Merge branch 'master' of https://github.com/MicrosoftDocs/sql-docs-pr into release-remove-sscurrent-tag
2 parents 5c0a66a + d4f1406 commit 26ff836

9 files changed

Lines changed: 507 additions & 32 deletions

docs/connect/ado-net/sql/azure-active-directory-authentication.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ For more information about managed identities, see [About managed identities for
165165

166166
Since **Microsoft.Data.SqlClient** 2.1.0, the driver supports authentication to Azure SQL Database, Azure Synapse Analytics, and Azure SQL Managed Instance by acquiring access tokens via managed identity. To use this authentication, specify either `Active Directory Managed Identity` or `Active Directory MSI` in the connection string, and no password is required.
167167

168-
You can't set the `Credential` property of `SqlConnection` in this mode either. For a user-assigned managed identity, username must be provided.
168+
You can't set the `Credential` property of `SqlConnection` in this mode either. For a user-assigned managed identity, the object id of the managed identity must be provided.
169169

170170
The following example shows how to use `Active Directory Managed Identity` authentication with a system-assigned managed identity.
171171

@@ -189,7 +189,7 @@ The following example demonstrates `Active Directory Managed Identity` authentic
189189

190190
```c#
191191
// For user-assigned managed identity
192-
// Use your own server, database, and user ID.
192+
// Use your own values for Server, Database, and User Id.
193193
string ConnectionString1 = @"Server=demo.database.windows.net; Authentication=Active Directory Managed Identity; User Id=ObjectIdOfManagedIdentity; Database=testdb";
194194

195195
using (SqlConnection conn = new SqlConnection(ConnectionString1)) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
author: WilliamDAssafMSFT
3+
ms.service: sql
4+
ms.topic: include
5+
ms.date: 04/09/2021
6+
ms.author: wiassaf
7+
---
8+
9+
<Token>![yes](../media/yes-icon.png)[!INCLUDE [ssazuresynapse_sqlpool_only](../ssazuresynapse-svrless-sqlpool-only.md)]</Token>
10+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
author: WilliamDAssafMSFT
3+
ms.service: sql
4+
ms.topic: include
5+
ms.date: 04/09/2021
6+
ms.author: wiassaf
7+
---
8+
9+
[!INCLUDE [Applies to](../../includes/applies-md.md)] [!INCLUDE [Azure SQL Database](../../includes/applies-to-version/_asdb.md)] [!INCLUDE [SQL Managed Instance](../../includes/applies-to-version/_asdbmi.md)] [!INCLUDE [Azure Synapse Analytics (serverless SQL pool only)](../../includes/applies-to-version/_asa-svrless-sqlpool-only.md)]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
author: WilliamDAssafMSFT
3+
ms.service: sql
4+
ms.topic: include
5+
ms.date: 04/09/2021
6+
ms.author: wiassaf
7+
---
8+
9+
Azure Synapse Analytics (serverless SQL pool only)

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

Lines changed: 30 additions & 30 deletions
Large diffs are not rendered by default.

docs/relational-databases/system-stored-procedures/sp-dropdistpublisher-transact-sql.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ sp_dropdistpublisher [ @publisher = ] 'publisher'
3636
## Arguments
3737
`[ @publisher = ] 'publisher'`
3838
Is the Publisher to drop. *publisher* is **sysname**, with no default.
39+
40+
> [!NOTE]
41+
> If the SQL Server publisher is configured with a custom port, then when dropping such a publisher on the distributor, supply the publisher server name instead of `<Hostname>,<PortNumber>`.
3942
4043
`[ @no_checks = ] no_checks`
4144
Specifies whether **sp_dropdistpublisher** checks that the Publisher has uninstalled the server as the Distributor. *no_checks* is **bit**, with a default of **0**.
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
---
2+
description: "Logical Functions - GREATEST (Transact-SQL)"
3+
title: "GREATEST (Transact-SQL)"
4+
ms.custom: ""
5+
ms.date: "04/09/2021"
6+
ms.prod: sql
7+
ms.prod_service: "database-engine, sql-database"
8+
ms.technology: t-sql
9+
ms.topic: reference
10+
f1_keywords:
11+
- "GREATEST"
12+
- "GREATEST_TSQL"
13+
dev_langs:
14+
- "TSQL"
15+
helpviewer_keywords:
16+
- "GREATEST function"
17+
author: jmsteen
18+
ms.author: josteen
19+
ms.reviewer: wiassaf
20+
---
21+
# Logical Functions - GREATEST (Transact-SQL)
22+
[!INCLUDE [asdb-asdbmi](../../includes/applies-to-version/asdb-asdbmi.md)]
23+
24+
This function returns the maximum value from a list of one or more expressions.
25+
26+
![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
27+
28+
## Syntax
29+
30+
```syntaxsql
31+
GREATEST ( expression1 [ ,...expressionN ] )
32+
```
33+
34+
## Arguments
35+
*expression1, expressionN*
36+
A list of comma-separated expressions of any comparable data type. The `GREATEST` function requires at least one argument and supports no more than 254 arguments.
37+
38+
Each expression can be a constant, variable, column name or function, and any combination of arithmetic, bitwise, and string operators. Aggregate functions and scalar subqueries are permitted.
39+
40+
## Return types
41+
Returns the data type with the highest precedence from the set of types passed to the function. For more information, see [Data Type Precedence &#40;Transact-SQL&#41;](../../t-sql/data-types/data-type-precedence-transact-sql.md).
42+
43+
If all arguments have the same data type and the type is supported for comparison, `GREATEST` will return that type.
44+
45+
Otherwise, the function will implicitly convert all arguments to the data type of the highest precedence before comparison and use this type as the return type.
46+
47+
For numeric types, the scale of the return type will be the same as the highest precedence argument, or the largest scale if more than one argument is of the highest precedence data type.
48+
49+
## Remarks
50+
All expressions in the list of arguments must be of a data type that is comparable and that can be implicitly converted to the data type of the argument with the highest precedence.
51+
52+
Implicit conversion of all arguments to the highest precedence data type takes place before comparison.
53+
54+
If implicit type conversion between the arguments is not supported, the function will fail and return an error.
55+
56+
For more information on implicit and explicit conversion, see [Data Type Conversion &#40;Database Engine&#41;](../../t-sql/data-types/data-type-conversion-database-engine.md).
57+
58+
If one or more arguments are not `NULL`, then `NULL` arguments will be ignored during comparison. If all arguments are `NULL`, then `GREATEST` will return `NULL`.
59+
60+
Comparison of character arguments follows the rules of [Collation Precedence &#40;Transact-SQL&#41;](../../t-sql/statements/collation-precedence-transact-sql.md).
61+
62+
The following types are **not** supported for comparison in `GREATEST`: **varchar(max), varbinary(max) or nvarchar(max) exceeding 8,000 bytes, cursor, geometry, geography, image, non-byte-ordered user-defined types, ntext, table, text**, and **xml**.
63+
64+
The varchar(max), varbinary(max), and nvarchar(max) data types are supported for arguments that are 8,000 bytes or below, and will be implicitly converted to varchar(n), varbinary(n), and nvarchar(n), respectively, prior to comparison.
65+
66+
For example, varchar(max) can support up to 8,000 characters if using a single-byte encoding character set, and nvarchar(max) can support up to 4,000 byte-pairs (assuming UTF-16 character encoding).
67+
68+
## Examples
69+
70+
### A. Simple example
71+
72+
The following example returns the maximum value from the list of constants that is provided.
73+
74+
The scale of the return type is determined by the scale of the argument with the highest precedence data type.
75+
76+
```sql
77+
SELECT GREATEST ( '6.62', 3.1415, N'7' ) AS Greatest;
78+
GO
79+
```
80+
81+
[!INCLUDE[ssResult](../../includes/ssresult-md.md)]
82+
83+
```
84+
Greatest
85+
--------
86+
7.0000
87+
88+
(1 rows affected) 
89+
```
90+
91+
### B. Simple example with character types
92+
93+
The following example returns the maximum value from the list of character constants that is provided.
94+
95+
```sql
96+
SELECT GREATEST ('Glacier', N'Joshua Tree', 'Mount Rainier') AS Greatest;
97+
GO
98+
```
99+
100+
[!INCLUDE[ssResult](../../includes/ssresult-md.md)]
101+
102+
```
103+
Greatest
104+
-------------
105+
Mount Rainier
106+
107+
(1 rows affected) 
108+
```
109+
110+
### C. Simple example with table
111+
112+
This example returns the maximum value from a list of column arguments and ignores `NULL` values during comparison.
113+
114+
```sql
115+
USE AdventureWorks2019;
116+
GO
117+
118+
SELECT sp.SalesQuota, sp.SalesYTD, sp.SalesLastYear
119+
, GREATEST(sp.SalesQuota, sp.SalesYTD, sp.SalesLastYear) AS Greatest
120+
FROM sales.SalesPerson AS sp
121+
WHERE sp.SalesYTD < 3000000;
122+
GO
123+
124+
```
125+
126+
[!INCLUDE[ssResult](../../includes/ssresult-md.md)]
127+
128+
```
129+
SalesQuota SalesYTD SalesLastYear Greatest
130+
131+
--------------------- --------------------- --------------------- ---------------------
132+
NULL 559697.5639 .0000 559697.5639
133+
250000.0000 1453719.4653 1620276.8966 1620276.8966
134+
300000.0000 2315185.6110 1849640.9418 2315185.6110
135+
250000.0000 1352577.1325 1927059.1780 1927059.1780
136+
250000.0000 2458535.6169 2073505.9999 2458535.6169
137+
250000.0000 2604540.7172 2038234.6549 2604540.7172
138+
250000.0000 1573012.9383 1371635.3158 1573012.9383
139+
300000.0000 1576562.1966 .0000 1576562.1966
140+
NULL 172524.4512 .0000 172524.4512
141+
250000.0000 1421810.9242 2278548.9776 2278548.9776
142+
NULL 519905.9320 .0000 519905.9320
143+
250000.0000 1827066.7118 1307949.7917 1827066.7118
144+
145+
(12 rows affected)
146+
147+
```
148+
### D. Using `GREATEST` with local variables
149+
150+
This example uses `GREATEST` to determine the maximum value of a list of local variables within the predicate of a `WHERE` clause.
151+
152+
```sql
153+
CREATE TABLE studies (
154+
Variable varchar(10) NOT NULL,
155+
Correlation decimal(4, 3) NULL
156+
);
157+
158+
INSERT INTO studies VALUES ('Var1', 0.2), ('Var2', 0.825), ('Var3', 0.61);
159+
GO
160+
161+
DECLARE @PredictionA DECIMAL(2,1) = 0.7;
162+
DECLARE @PredictionB DECIMAL(3,1) = 0.65;
163+
164+
SELECT Variable, Correlation
165+
FROM studies
166+
WHERE Correlation > GREATEST(@PredictionA, @PredictionB);
167+
GO
168+
```
169+
170+
[!INCLUDE[ssResult](../../includes/ssresult-md.md)]
171+
172+
```
173+
Variable Correlation
174+
---------- -----------
175+
Var2 .825
176+
177+
(1 rows affected)
178+
```
179+
180+
### E. Using `GREATEST` with columns, constants, and variables
181+
182+
This example uses `GREATEST` to determine the maximum value of a list that includes columns, constants, and variables.
183+
184+
```sql
185+
CREATE TABLE products (
186+
prod_id int IDENTITY(1,1),
187+
listprice smallmoney NULL
188+
);
189+
190+
INSERT INTO products VALUES (14.99), (49.99), (24.99);
191+
GO
192+
193+
DECLARE @PriceX smallmoney = 19.99;
194+
195+
SELECT GREATEST(listprice, 0, @PriceX) as GreatestPrice
196+
FROM products;
197+
GO
198+
```
199+
200+
[!INCLUDE[ssResult](../../includes/ssresult-md.md)]
201+
202+
```
203+
GreatestPrice
204+
-------------
205+
19.9900
206+
49.9900
207+
24.9900
208+
209+
(3 rows affected)
210+
```
211+
212+
213+
## See also
214+
[LEAST &#40;Transact-SQL&#41;](../../t-sql/functions/logical-functions-least-transact-sql.md)
215+
[MAX &#40;Transact-SQL&#41;](../../t-sql/functions/max-transact-sql.md)
216+
[MIN &#40;Transact-SQL&#41;](../../t-sql/functions/min-transact-sql.md)
217+
[CASE &#40;Transact-SQL&#41;](../../t-sql/language-elements/case-transact-sql.md)
218+
[CHOOSE &#40;Transact-SQL&#41;](../../t-sql/functions/logical-functions-choose-transact-sql.md)
219+
220+

0 commit comments

Comments
 (0)