Skip to content

Latest commit

 

History

History
57 lines (43 loc) · 2.06 KB

File metadata and controls

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

%= (Modulus assignment) (Transact-SQL)

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

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

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