In SQL Server, you can use the ROWCOUNT_BIG()
system function to return the number of rows affected by the last T-SQL statement.
It works exactly the same as @@ROWCOUNT
, except that ROWCOUNT_BIG()
returns its result as a bigint.
In SQL Server, you can use the ROWCOUNT_BIG()
system function to return the number of rows affected by the last T-SQL statement.
It works exactly the same as @@ROWCOUNT
, except that ROWCOUNT_BIG()
returns its result as a bigint.
In SQL Server, you can use the SET SHOWPLAN_ALL
statement to return detailed information about how a T-SQL statement is executed, as well as estimates of the resource requirements for the statements.
In SQL Server, you can use the SET SHOWPLAN_TEXT
statement to return detailed information about how a T-SQL statement is executed.
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.
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.
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.
In SQL Server, you can use the SET STATISTICS IO
statement to generate detailed information about the amount of disk activity generated by a T-SQL statement.
In graphical tools like SSMS and Azure Data Studio, you can view this information in the Messages tab.
Continue readingThe 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 <=
.
In SQL Server, you can use SET ROWCOUNT
to limit the rows returned by a query.
The way it works is that it causes SQL Server to stop processing the query after the specified number of rows are returned.
It’s similar to the TOP()
clause, but with the difference that SET ROWCOUNT
is set outside of the query, and will affect all subsequent queries.
In SQL Server, you can use the SOME
logical operator to compare a scalar value with a single-column set of values returned by a subquery.
It can be used with subqueries that have a result set of one column.
The SOME
operator is the equivalent of the ANY
logical operator.