Uncategorized

The Urge to Merge

New SelecTViews Show – Josh Jones/SharePoint
Josh Jones is on the show today, talking about getting up to speed on SharePoint and surprises about working with SharePoint. Also, what has Josh found to be the keys to working with SharePoint? Find out on the show today.
[Watch the Show Here]

Webcast: Operational Excellence for DBAs, Part 1: Setup and Configuration
This session covers key setup and configuration questions faced when setting up a new SQL Server, from the bare metal configuration on up. What difference does the CPU make? How important is 32-bit versus 64-bit? Should I virtualize? What kind of disk subsystem do I need? What edition of SQL Server is best for this application and how should it be licensed? What’s a good "starter" configuration compared to a "high-end" configuration? What difference do important SP_CONFIGURE settings make to system performance?

> Register Now
> Live date: 11/10/2010 at 12:00 Pacific

Going to PASS? Important Happenings…
Kalen Delaney posted a very cool project that’s happening at PASS – and you can help! Check it out here.

Here’s the summary:
Corner of Love leads mission teams to villages in impoverished northern Nicaragua, providing life changing medicines, dental care, and basic personal hygiene items. Coupled with service projects like establishing safe/clean water sources, this will promote an improvement in the general health level of these communities.

If you can donate any items, including leftover hotel amenities, please drop them by the Red Gate booth during the expo at booth #408

Featured Article(s)
What and Why should I use an Execution Plan…
When you hear about Execution plans does football come to mind? Do you think about making sure you have coffee before you go to work? If so you may want to consider reviewing what a SQL Server Execution plan can do for you.

Featured White Paper(s)
Why and How You Should Find and Fix Index Fragmentation
In a high-volume database you need frequent critical maintenance. If you skip this important task, index fragmentation may ca… (read more)

The Urge to Merge
One of the coolest features of the SQL Server 2008 release was the new Merge statement. What really makes it cool is it saves a lot of coding. It takes two sets, and merges the differences between the two,

In the past, I might have a data warehouse I wish to update with newly extracted from a production system. I would have to write as many as three queries.

  1. Update existing rows with modifications from the production system
  2. Insert new rows from the production system
  3. Delete rows from the warehouse that are no longer in the production system

I can always ignore any of the three queries that do not apply.

The new (to SQL Server 2008) merge statement allows you to do all three of these queries in a single step. The neat thing about it is that you have the ability to choose what to do for each of these three scenarios as well. Now that’s cool.

I remember creating a stored procedure a few years ago that would write those three queries because it was something that happened all the time. I worked on a system where data was copied from the database to a web server, and after users made modifications, the whole thing was submitted back to the database again to have the changes merged in. I wish we had SQLMerge back then. Life would have been a lot easier.

If you are interested you can see more about Merge in BOL. You can find help in the SQL Server 2008 TSQL Fundamentals book as well.

Got other SQL Tips you want to share with our readers. Send your comments to btaylor@sswug.org.

Cheers,
Ben