Deterministic functions always return the same result whenever they are called with a specific set of input values provided the database state remains unchanged. Non-deterministic functions may return different results each time they are called with a specific set of input values even if the database state remains unchanged. In another… Continue Reading Deterministic Functions in SQL

Ranking function  help us assigning a rank value for each row in your result-set. They support the windowing the partition too. Books Online states that these functions are non-deterministic. These are the ranking functions available in SQL Server. RANK() Returns the rank of each row within a result set. The… Continue Reading Ranking Funtions – Explained

What is SARGability? The word SARGable comes from the term “Search ARGumentable”. This tells if an item can be found by using an index, provided such an index is available. Understanding sargability can really impact the  ability to write well-performing queries. If a WHERE clause is not sargable, the Query Optimizer… Continue Reading What makes a query SARGable?

What is the escape character in SQL? Assume you have to find the the names that contains single quote (‘), in this scenario single quote(‘) itself works as the escape character.  SELECT * FROM Person.Person WHERE LastName LIKE ‘%”%’ Consider the situation where you are tying to find records which… Continue Reading Escape Character – MS SQL

Often many ask, what is the difference between union and union all? Union operator combines multiple resultsets into one resultset. Union also removes the duplicates and returns a sorted result set. Union All  operator combine multiple resultsets into one resultset, but it does not eliminate the duplicate rows.  Since the duplicate… Continue Reading Union v/s Union All