Skip to content

Commit db96a1f

Browse files
authored
Merge pull request #3125 from BYHAM/patch-434
Divide equals, added example.
2 parents cb85f2d + 31fc48f commit db96a1f

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

docs/t-sql/language-elements/divide-equals-transact-sql.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "(Divide EQUALS) (Transact-SQL) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "03/06/2017"
4+
ms.date: "09/12/2017"
55
ms.prod: "sql-non-specified"
66
ms.reviewer: ""
77
ms.suite: ""
@@ -26,15 +26,13 @@ manager: "jhubbard"
2626
# (Divide EQUALS) (Transact-SQL)
2727
[!INCLUDE[tsql-appliesto-ss2008-all_md](../../includes/tsql-appliesto-ss2008-all-md.md)]
2828

29-
Divides one number by another and sets a value to the result of the operation. For example, if a variable @x equals 34, then @x /= 2 takes the original value of @x, divides by 2 and sets @x to that new value (17).
29+
Divides one number by another and sets a value to the result of the operation. For example, if a variable @x equals 34, then `@x /= 2` takes the original value of @x, divides by 2 and sets @x to that new value (17).
3030

3131
![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)
3232

3333
## Syntax
3434

3535
```
36-
-- Syntax for SQL Server, Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse
37-
3836
expression /= expression
3937
```
4038

@@ -47,10 +45,24 @@ expression /= expression
4745

4846
## Remarks
4947
For more information, see [(Divide) (Transact-SQL)](../../t-sql/language-elements/divide-transact-sql.md).
48+
49+
## Examples
50+
The following example, sets a variable to 17. Then uses the `/=` operator to set the variable to half of it's original value.
51+
```sql
52+
DECLARE @myVariable decimal(5,2);
53+
SET @myVariable = 17.5;
54+
SET @myVariable /= 2;
55+
SELECT @myVariable AS ResultVariable;
56+
```
5057

58+
[!INCLUDE[ssresult-md](../../includes/ssresult-md.md)]
59+
|ResultVariable |
60+
|--- |
61+
|8.75 |
62+
5163
## See Also
5264
[Compound Operators (Transact-SQL)](../../t-sql/language-elements/compound-operators-transact-sql.md)
5365
[Expressions (Transact-SQL)](../../t-sql/language-elements/expressions-transact-sql.md)
5466
[Operators (Transact-SQL)](../../t-sql/language-elements/operators-transact-sql.md)
5567

56-
68+

0 commit comments

Comments
 (0)