SQL SERVER – Using RANKING Functions Instead of SQL Looping Logic of Cursor – Quiz – Puzzle – 8 of 31

Click here to get free chapters (PDF) in the mailbox

Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective.

Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The quiz is indeed focused on my two goals. In addition, it’s going to put the learning of the book to a higher stage. Looking at this novel concept, Vinod Kumar (Co-author) and I have decided to help every participant and reader by giving a few hints and suggestions to solve the quiz.

SQL Quiz

SQL SERVER - Using RANKING Functions Instead of SQL Looping Logic of Cursor - Quiz - Puzzle - 8 of 31 8

An SQL developer got surprised when he learned that he does not have to use cursors to calculate ranks in SQL Server 2008. He can now just use the newly introduced ranking functions. What are the different RANKING functions inside SQL Server 2008 R2 and what are the new functions introduced inside SQL Server 2012?

Link to participate in SQL Quiz

Notes of Vinod Kumar

This is a give away as a hint. But there are specific differences when it comes to each of these. Can you think of a scenario to use each of them effectively? Hint: Just think of a school and you will find ways of using them. :)

Notes of Pinal Dave

I still remember my first manager and his advice: “Take a walk, when you have to use cursor”. I still remember this and follow it every single time; I just have to use cursor. Cursors are not always bad, but if it is used without proper understanding and without considering other alternatives, it is indeed a bad decision to use. I have often seen cases where there were alternate ready-made solutions available, but still the developer went ahead and implemented a cursor that was not optimized (hogging resources). I personally insist on always learning all the new features of SQL Server as I often figure out alternative of cursors when I am exploring new features.

Additional Notes

SQL Server Interview Questions and Answers ISBN: 1466405643 Page#128-129
Use INSERT INTO … SELECT instead of Cursor
Simple Use of Cursor to Print All Stored Procedures of Database
Simple Use of Cursor to Print All Stored Procedures of Database Including Schema
Simple Example of Cursor
Cursor to Kill All Process in Database


There are exciting prizes awaiting the winners. Click here for Prizes and Frequently Asked Questions.

Link to participate in SQL Quiz

Note: The SQL Quiz, winners and prizes are administrated by Beyond Relational. The goal of this blog post is to provide additional learning pointers only.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Previous Post
SQL SERVER – Indexed Views and Restrictions – Quiz – Puzzle – 7 of 31
Next Post
SQL SERVER – Locking, Blocking and Deadlock – Quiz – Puzzle – 9 of 31

Related Posts

No results found.

Leave a Reply