Nov 6, 2009

A Scenario to Ponder #15

I guess, by now, most of you are familiar with the SQL Server 2005 sample database - AdventureWorks. We will use one of the tables from this database to create our scenario - Production.BillOfMaterials. To simplify our requirements, we will be selecting only those records in this table, that has the EndDate as NULL.

Oct 28, 2009

Understanding Transaction Isolation Levels in SQL Server

One of the most important concepts pertaining to any DBMS that every database programmer must know is the Transaction Isolation Levels. Sometimes, even the most seasoned database developers get confused on how multiple connections running in different isolation levels affect each other. This post is an attempt to explain through examples on how the isolation levels differ from each other.

Oct 23, 2009

Custom Sorting and Paging in SQL Server Stored Procedure

This post is about achieving pagination using stored procedure, without using dynamic SQL. The solution presented should work for both SQL Server 2000 and 2005.

Most of the web application displaying transactional data will have a data grid with sorting and paging functionality and some filter criteria.

We usually use the default sorting/paging functionality available in the datagrid. But, this requires the entire search resultset to be cached in the client side, which is fine for a few hundered records but can be a drag as the number of records increase.

Oct 10, 2009

A Scenario to Ponder #14

Lots of things happened since the last post I made in this blog. I got married. Didn't do much justice to my blog followers since then. My wife couldn't stand me being interested in ONLY her :) So, she pushed me to get this blog started again and I hope she keeps pushing me to continue this blog.

Now, Here is the scenario.
I had been playing Chicktionary (google it if you had not heard of it) in Club Bing. There are some other versions of the same game - Word Warp, Text Twist, Jumble, etc. In a gist, its a game where you are given a chain of letters and you need to come up with as many words as you can with these letters in a given time. It's a pretty addictive game.

Oct 9, 2007

A Scenario to Ponder #13

Last February, I had come over to Atlanta, Georgia from India for a new project and had been quite overwhelmed by the new way of life, the work and the country that I wasn't able to do justice to this blog. I apologize for those who had been following this mini series of scenarios. Hope I can get some time now to revive this.

Here goes the scenario:

Feb 7, 2007

A Scenario to Ponder #12

Its been a long time since I had used this medium of communication. Without getting into the excuses part of the dormancy I will get on with the question...

Here is the scenario. Say, I am in a business consulting company and I am given a table EmployeeCustomerOrders.

The table can be generated from the orders table in the Northwind database using this query.

Dec 4, 2006

Obvious SQL Tip #2

Thinking in sets:
The thought process that goes into set- based programming is slightly different from writing procedural code.

Say, I have 2 tables -one holding order header information and the other holding the details of the products ordered. I want to get the items ordered for all the orders:

  • The procedural way of looking at it is "for each order in the orders table get the order details from the [order details] table".
  • In DB terms, its "for all orders in the orders table get the order details from the [order details] table".