Logical Operators

I am going to make headway on the series of very short articles or tidbits on Transaction SQL Operators. An operator is a symbol specifying an action that is performed on one or more expressions. I will exploring the Logical Operators today. In short, these operators return either a boolean TRUE or FALSE. To demonstrate many of these operators, we need a temporary table to query against. The Transaction SQL code below creates a table that contains the first eight prime numbers. Any complex real world programming example probably has…

Compound Operators

I am going to forge ahead with my series of very short articles or tidbits on Transaction SQL Operators. An operator is a symbol specifying an action that is performed on one or more expressions. I will exploring the Compound Operators today. These operators are a short hand for taking a variable @V, applying some operator O and storing the result as variable @V. A long way to write out adding 2 to variable @V is the expression @V = @V + 2 while the short way is the expression…

Comparison Operators – Part 2

I am going pick up writing my series of very short articles or tidbits on Transaction SQL Operators. An operator is a symbol specifying an action that is performed on one or more expressions. I will continue examining the Comparison Operators today. These comparison operators are known as the less than = symbols in inequality and equality mathematics. I will be examining how a sample operator works with character, date/time, money and binary data types. Remember, character data types use the ASCII or UNICODE chart to determine if one character…

Comparison Operators – Part 1

I am going to keep the ball rolling with my series of very short articles or tidbits on Transaction SQL Operators. An operator is a symbol specifying an action that is performed on one or more expressions. I will exploring the Comparison Operators today. These comparison operators are known as the less than = symbols in inequality and equality mathematics. There are both ANSI standard and Microsoft specific comparison operators. I will be using the tiny integer data type to declare variables in the examples below. This allows us to…

Bitwise Operators

I am going to carry one with my series of very short articles or tidbits on Transaction SQL Operators. An operator is a symbol specifying an action that is performed on one or more expressions. I will exploring the Bitwise Operators today. Every piece of data on a computer is stored as a series of bits, either 1 or 0. Four bits are grouped together to become what is called a nibble. Two nibbles are combined to become a byte. The least significant bits are named lower nibble and the…

Assignment Operator

I am going to continue the series of very short articles or tidbits on Transaction SQL Operators. An operator is a symbol specifying an action that is performed on one or more expressions. I will exploring the Assignment Operator today. This equality symbol = in mathematics. There are two ways in which the assignment operator can be used: alias – associating a column heading with a expression or storage – placing the results of a expression into a variable. The TSQL example below compares the assignment operator against old and…

Arithmetic Operators

I am going to start a series of very short articles or tidbits on Transaction SQL Operators. An operator is a symbol specifying an action that is performed on one or more expressions. I will exploring the Arithmetic Operators today. The very first practical use of modern day computers was to solve mathematical problems. The ENIAC computer in 1946 was used by the United States Army to create artillery firing tables. TSQL supports the following five basic operations: addition, subtraction, multiplication, division and modulus. Most people know the first four…

String Functions – UPPER()

I am going to continue my series of very short articles or tidbits on Transaction SQL string functions. I will exploring the UPPER() function today. The UPPER() function takes a source string as input and returns a output string with all alpha characters converted to upper case. The following example converts the favorite movie title of mine to upper case.

One thing to always worry about when using TSQL functions is how will it react with empty strings or NULL values? Both empty strings and NULL values as…

String Functions – UNICODE()

I am going to write a series of very short articles or tidbits on Transaction SQL (TSQL) functions. I will exploring the UNICODE() function today. Transaction SQL (TSQL) supports the UNICODE() function that takes a NCHAR or NVARCHAR datatype as input and returns a INT datatype as output. The output value corresponds to the unicode characters location in a chart. This value can range from 0 to 65535. The following example returns the unicode value for a space which is a value of 32.

One thing to always…

String Functions – SUBSTRING()

I am going to continue my series of very short articles or tidbits on Transaction SQL string functions. I will exploring the SUBSTRING() function today. The SUBSTRING() function allows a developer to slice and dice a string into pieces. It takes a source string [T], a integer starting position [S], and a the number of characters [C] to return as input parameters. It returns a string of [C] characters from position [S] as output. The example below extracts one word from a famous movie title.

One thing to…