T-SQL: Compound Operators

Performing shorthand arithmetic

While it’s possible to perform simple arithmetic operations by repeating the use of variables, shorthand notation provides a much more efficient way of writing the same operations.

In the examples below, notice not once do I repeat a variable to perform an operation (increment, decrement, etc.).
Instead of writing “value = value + 1,” I write “value += 1,” thus, saving syntax from needless repetition.1-T-SQL-Compound-Operators

Incrementing

2-T-SQL-Compound-Operators

Decrementing 3-T-SQL-Compound-Operators

Dividing 4-T-SQL-Compound-Operators

Multiplying 5-T-SQL-Compound-Operators

The remainder from division 6-T-SQL-Compound-Operators

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s