• Skip to main content
  • Skip to primary sidebar

DBA Diaries

Thoughts and experiences of a DBA working with SQL Server and MySQL

sql server 2008

T-SQL – Determine the Difference in Values Between Columns in Different Rows

June 21, 2015 by Andy Hayes Leave a Comment

Calculate Difference Between Columns in Different Rows

Have you ever needed to calculate the difference between columns in two or more rows in a table using a T-SQL query? For example you might want to run some trend analysis or audit data for changes. Thankfully using ROW_NUMBER() and Common Table Expressions (CTE's), this can easily be achieved. --create our table DECLARE @TableRows TABLE ( DateAdded SMALLDATETIME, Points … [Read more...] about T-SQL – Determine the Difference in Values Between Columns in Different Rows

SQL Server Certification – 2 for 1 exam offer

April 29, 2012 by Andy Hayes Leave a Comment

I came across this today and wanted to share it with you. If you are interested in SQL Server certification then for a limited time, Microsoft are offering "2 for 1" on SQL Server exams. Between April 11 2012 and June 30 2012, you can purchase a SQL Server exam at full price and then once you have taken it you will be emailed a voucher for the second exam at no additional … [Read more...] about SQL Server Certification – 2 for 1 exam offer

SQL Server covering index and key lookup performance

April 15, 2012 by Andy Hayes 7 Comments

covering index key lookup

In this post, I wanted to write about the covering index and key lookup and how adding covering indexes can help increase performance by reducing lookups to the table data. It's helpful to know what each of these terms mean and then we will look at an example scenario further down the post. What is a covering index? A covering index is a non-clustered index which includes … [Read more...] about SQL Server covering index and key lookup performance

GROUPING SETS performance versus UNION performance

January 2, 2012 by Andy Hayes 1 Comment

GROUPING SETS is a way of aggregating data to produce a result set containing different sets of columns. For the SQL Server platform, it was first introduced in SQL 2008. Prior to SQL Server 2008, achieving this type of result set was possible using UNION, WITH CUBE, WITH ROLLUP and a helper function called GROUPING to achieve similar results. The issues with WITH CUBE … [Read more...] about GROUPING SETS performance versus UNION performance

Primary Sidebar

Categories

  • All Articles (82)
  • Career Development (8)
  • MySQL Administration (18)
  • MySQL Performance (2)
  • SQL Server Administration (24)
  • SQL Server News (3)
  • SQL Server Performance (14)
  • SQL Server Security (3)
  • SQL Tips and Tricks (19)

Top 10 Popular Posts

  • Using sp_change_users_login to fix SQL Server orphaned users
  • MySQL SHOW USERS? – How to List All MySQL Users and Privileges
  • How to shrink tempdb
  • How to Transfer Logins to Another SQL Server or Instance
  • How to Delete Millions of Rows using T-SQL with Reduced Impact
  • T-SQL – How to Select Top N Rows for Each Group Using ROW_NUMBER()
  • New T-SQL features in SQL Server 2012 – OFFSET and FETCH
  • How to Kill All MySQL Processes For a Specific User
  • Using exec sp_who2 to help with SQL Server troubleshooting
  • How to move tempdb

Recent Posts

  • How to Setup MySQL Master Master Replication
  • How To Use SQL to Convert a STRING to an INT
  • How to set up MySQL Replication Tutorial
  • How to Use SQL CASE for Conditional Logic in Your SQL Queries
  • Using ISNULL in SQL Server to Replace NULL Values

Search

Connect

  • Twitter
  • Facebook
  • Google+
  • RSS

About

  • Cookie Policy
  • Disclaimer
  • About
Copyright ©