SQL Server CASE Expression

In SQL Server, the T-SQL CASE expression is a scalar expression that returns a value based on conditional logic. It evaluates a list of conditions and returns a value, based on the outcome of those conditions..

In some ways, the SQL Server CASE expression is similar to IF...ELSE. However, CASE allows you to check for multiple conditions, whereas IF...ELSE doesn’t.

Continue reading

What is STATISTICS TIME in SQL Server?

In SQL Server, you can use the SET STATISTICS TIME statement to display the time it takes to execute a T-SQL statement.

More specifically, it returns the number of milliseconds required to parse, compile, and execute each statement.

When SET STATISTICS TIME is ON, the time statistics for a statement are displayed. When OFF, the time statistics are not displayed.

The setting of SET STATISTICS TIME is set at execute or run time and not at parse time.

Continue reading

What is STATISTICS PROFILE in SQL Server?

In SQL Server, you can use the SET STATISTICS PROFILE statement to display the profile information for a T-SQL statement.

STATISTICS PROFILE works for ad hoc queries, views, and stored procedures.

When STATISTICS PROFILE is set to ON, each executed query returns its regular result set, followed by an additional result set that shows a profile of the query execution.

Continue reading

How to Use the BETWEEN Operator in SQL Server

The SQL Server BETWEEN operator allows you to test between a range of values in your queries. For example, you could test that a value is between two numbers.

The BETWEEN operator is inclusive, meaning that it includes the values that you specify within the range. That is, it includes values that are greater than or equal to the lower value, and values that are less than or equal to the higher value. Therefore it’s like using >= and <=.

Continue reading