Archive: December 2011

  • Introduction to T-SQL Merge Basics

    A number of Frog-Blog posts over the next couple of months are going to make heavy use of the awesome SQL Server MERGE statement, introduced in SQL Server 2008. I thought it best to write an introduction post to provide the basics and groundwork for future posts. So what does the Merge statement do? Merge upserts data into a table. If, like me, you find the word ‘upsert’ more than a little ridiculous, we can scrap it in favour of a slightly…

    » Read more
  • Fast record count in SQL Server using sp_spaceused

    Just a quick tidbit today, but a very useful one. Ever need to do SELECT Count(*) on a very large table? It can take ages. Instead, use sp_spaceused EXEC sp_spaceused 'MyTable' It returns you a useful result set like name rows reserved data index_size unused MyTable 19690290 13637488 KB 3001688 KB 9986416 KB 649384 KB Not only does it also give you extra useful information about the table, but it comes back virtually instantly. Columns:…

    » Read more