Links for the Week of 2009.05.01

SQL SERVER Where isn’t there automatic in SQL Server? What’s great is that a co-worker and I were arguing about this very thing last night. He wanted to know why there wasn’t a ‘better language’ than SQL to use that would make it easier/more optimal to use functions while querying a database. I tried to explain that it wasn’t SQL that was the issue but dealing with a variety of optimizations and what not.

Solving Business Problems with SQL

Businesses have all kind of interesting rules for working with data. Sometimes these rules are incredibly easy to implement in the database. Sometimes these rules are incredibly to implement in the application layer. Sometimes, it’s difficult to construct these rules no matter where you are in the entire application stack. I recently came across a situation that required a bit of head scratching before I got things working correctly. What made this incredibly interesting to me was the apparent simplicity of the business rules.

Links for the Week of 2009.04.24

SQL SERVER Filtered Indexes: What You Need To Know Michelle Ufford dives into the wonders of filtered indexes and explains what they are, why you need them, and how you can go about using them. Makes me wish we were on SQL Server 2008 at work. Use SQL 2008 Express as a Central Management Server Wish you had a central management server in the office to help you manage your mountain of SQL 2005 machines?

Populating U.S. Federal Holidays in a Calendar Table

The title of this blog is only half as thrilling as the SQL. I can assure you. I have a calendar table at work that is based off of the calendar table that you can find on aspfaq.com in an article titled Why should I consider using an auxiliary calendar table? The big problem is that the holidays in the script are not actually federal holidays. They’re just a set of holidays that seemed significant to the author at the time of writing.

Using Partitioning Functions to Find Duplicate Rows

Did you know that you can use the OVER clause, in conjunction with PARTITION BY to find duplicate rows in the database? Here’s a business case for you: There is a table consisting of UserId, SiteId, and ClientId:``` IF OBJECT_ID(‘window_test’) IS NOT NULL DROP TABLE window_test; CREATE TABLE window_test ( UserId INT, SiteId INT, ClientId INT ); Over time, data has been inserted into this table both through an application and through SSMS: INSERT INTO window_test SELECT 1, 1, 1 UNION ALL SELECT 1, 2, 2 UNION ALL SELECT 2, 1, 1 UNION ALL SELECT 3, 1, 1 UNION ALL SELECT 1, 3, 1;

Converting Measurements with T-SQL

I frequently find myself having to perform calculations on the source data based on a range of user supplied values. Usually there will be some kind of target and destination parameter supplied. So, for example, the users will want to see total sales in terms of burgers sold or something like that. Here’s where it gets tricky. Let’s say I own two franchises – one that sells burgers and one that sells tacos.

My First Microsoft Connect Item

I finally feel like a real SQL Server professional! I’ve submitted my first Connect feedback to Microsoft for a new feature of SQL Server: BOL for mobile devices. This is a dream I’ve had since I first got my grubby little paws on my iPhone. Every day since then I’ve dreamed of having a copy of SQL Server Books Online on my iPhone. It would be better than games and movies on my iPhone.

Links for the Week of 2009.04.17

SQL SERVER The DBA… their role, expectations and future? What should a DBA be doing on a daily basis? What does their job entail? Here’s one version of that idea. Spying on Your SPIDs: It’s sp_who but Better Even more info on how my users are ruining my database? YES PLEASE! DEVELOPMENT Using jQuery Grid With ASP.NET MVC jQuery: win. ASP.NET MVC: win. jQuery + ASP.NET: double win! Phil Haack walks through using custom jQuery controls in this quick tutorial on jQuery and ASP.

SQL Quiz, Part the Fourth!

I was tagged by Thomas LaRock in SQL Quiz 4. The topic of this round is: WHO HAS BEEN A GREAT LEADER IN YOUR CAREER AND WHAT MADE THEM A GREAT LEADER? Honestly, I’ve had a lot of great bosses in my career but have come across even more great leaders. Like SQLBatman, I think it’s more appropriate to talk about the traits that have made those people great leaders rather than the people themselves.

Check for the Existence of a Temp Table

Do you suffer from the pain of temporary tables hanging around long after you need them? Have you ever found yourself frantically googling, trying to remember the syntax to check for the existence of a temporary table before deleting it? I, too, used to suffer alongside you, dear readers. I, too, know your pain of re-running a script only to find that a temporary table was skulking around in memory somewhere, waiting to ruin my carefully crafted three-value logic.