Rank() function is used to give ranking to the records chosen through a select clause. Rank function is very commonly used in the industry for many purposes.
The general syntax of rank function is
RANK ( ) OVER ( [ partition by < column_list > ] order by <column_list> )
The PARTITION BY clause divides the result set produced by the FROM clause into separate partitions. Rank is applied to each of these partion.
The ORDER BY clause determines the order in which the RANK values are applied to the records in a partition.
Read more…
Categories: Functions, Functions and DMVs, Operators, SQL Queries, SQL Server, T-SQL, T-SQL Tags: order by, partition, query, rank, SQL Server, T-SQL
November 18th, 2010
admin
RAISERROR statement is used to return error messages to the business applications that executes SQL statements. The usual errors returned by the SQL server may not make much sense to the business applications users hence we overwrite it by using RAISERROR to display meaningful messages. The statement uses same format as a system error or warning messages generated by SQL server.
You can return a user-defined error message by using RAISERROR. The general syntax is as below
RAISERROR ( { msg_id | msg_str | @local_variable }
{ ,severity ,state }
[ ,argument [ ,...n ] ] )
[ WITH option [ ,...n ] ]
ExamplesRAISERROR (‘Error raised in TRY block.’, — Message text.
Read more…
Categories: Error Messages, Errors, Functions and DMVs, Operators, SQL Queries, SQL Server, T-SQL, T-SQL Tags: errors, functions, raiserror, sql queries, SQL Server, T-SQL, try catch
November 14th, 2010
admin
Logical operators can be used in the queries to retrieve records based on one more conditions. In a select statement, the conditions specified by the logical operators are connected using a WHERE clause.
General syntax :
Select ColumnList
From TableName
Where ConditionalExpr1 {AND/OR} [NOT] ConditionalExpr2
There are 3 types of logical operators
Read more…
Categories: Operators, Operators, SQL Queries, SQL Server, T-SQL, T-SQL Tags: and, logical operators, not operator, operators, or, sql queries, SQL Server, T-SQL