SQL Server Developer

Winning T-SQL Games from the Red Gate Software-Sponsored January 2006 Contest

This past January, Red Gate Software sponsored a T-SQL contest. The goal was to write a game in T-SQL that was fun to play. Below are the links to the three games that won. When you click on a link, you will be brought to a new page with the T-SQL code you need to […]

Top 10 Must Have Features in O/R Mapping Tools

Object-to-relational (O/R) mapping tools are becoming more popular each day and people are realizing the productivity gain they provide to developers. Yet, many people do not know enough about O/R mapping to consider using these tools and many others are weary of using any code generators (including O/R mapping tools). In this article, I will […]

Exception Handling in SQL Server 2000 and 2005

Error handling plays a vital role when writing stored procedures or scripts. In this article I will discuss error handling in SQL Server 2000 and SQL Server SQL Server 2005. Before starting the discussion of the error handling part, I will take you through the different components of an error message. Here is a typical […]

Ownership Chains in SQL Server 2005

When multiple database objects access each other sequentially, the sequence is known as a “chain.” Although such chains have no independent existence, when SQL Server is traversing the links in a chain, it evaluates user permissions on the constituent objects differently than it would if it were accessing them separately. These differences have important implications […]

Working With Temporary Views Using Common Table Expression in SQL Server 2005

When working with SQL 2005, there are times when you need to perform several aggregate functions, or to define a view that needs to be stored only during the execution of a particular query. A Common Table Expression (CTE) does just that; it helps in the definition and manipulation of query related results that need […]

Demystifying the SQL Server DATETIME Datatype

When you follow online communities dedicated to SQL Server with open eyes, you certainly notice a whole lot of questions are closely related to the DATETIME datatype in one way or the other. Obviously, working with DATETIME not as easy as it may seem. To me this seems kind of strange. My believe is that […]

Sending SQL Server Notifications with CDOSYS

While SQL Server has a very mature set of tools, one thing that is lacking is the ability to send a simple email alert based on a pre-defined set of rules. At first glace, it appears that email notifications exist, but what becomes a problem to many people is the requirement for a MAPI subsystem […]

Implementing Triggers in SQL Server 2000

Triggers are special types of Stored Procedures that are defined to execute automatically in place of or after data modifications. They can be executed automatically on the INSERT, DELETE and UPDATE triggering actions. There are two different types of triggers in Microsoft SQL Server 2000. They are INSTEAD OF triggers and AFTER triggers. These triggers […]

How to Delete SQL Server Database Duplicate Rows from a Table Using a Specified Column List and No Temp Tables

As much as we try and prevent it, duplicate data still finds its way into corporate data systems, but the good news is that purging duplicate rows can be a relatively simple task. Prevention, through the use of good match code algorithms and constraints, will stop most duplicate data from entering your databases, but there […]

Advanced SQL Server DATE and DATETIME Handling

There are lot of situations where you need an exact timestamp. For example, you may want to differentiate a recordsets’ creation dates, store technical measurements, or just to see how fast your latest SQL is running. Coding the 4th dimension is another common task, and therefore milliseconds are essential. But there is a problem receiving […]