Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 2.12 KB

modulo-equals-transact-sql.md

File metadata and controls

57 lines (42 loc) · 2.12 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs monikerRange
%= (Modulus assignment) (Transact-SQL)
The %= (modulus assignment) operator divides one number by another and sets a value to the result of the operation.
rwestMSFT
randolphwest
03/19/2024
sql
t-sql
reference
%=_TSQL
%=
%= (modulo equals)
%= (modulus assignment)
compound operators, %=
assignment operators, %=
augmented operators, %=
TSQL
>=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric

%= (Modulus assignment) (Transact-SQL)

[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw]

Divides one number by another and sets a value to the result of the operation. For example, if a variable @x equals 38, then @x %= 5 takes the original value of @x, divides by 5, and sets @x to the remainder of that division (3).

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

expression %= expression

[!INCLUDE sql-server-tsql-previous-offline-documentation]

Arguments

expression

Any valid expression of any one of the data types in the numeric category, except the bit data type.

Result types

Returns the data type of the argument with the higher precedence. For more information, see Data type precedence (Transact-SQL).

Remarks

For more information, see % (Modulus) (Transact-SQL).

Related content