Differences Between TRUNCATE TABLE and DELETE

If you want to remove data from a table, you can do this in a couple of ways using TRUNCATE TABLE or DELETE. A common approach is to use DELETE to remove all rows in the table but TRUNCATE TABLE offers an alternative and I will list what the differences between the two are. DELETE [...]

New T-SQL features in SQL Server 2012 – THROW

sql server 2012 throw

New in SQL Server 2012 as part of exception handling in T-SQL is THROW Exception handling in previous versions of SQL Server THROW will raise an exception inside of the catch block and there are already ways to do this in previous versions of SQL Server but where this is an improvement over previous methods [...]

New T-SQL features in SQL Server 2012 – WITH RESULT SETS

sql server 2012 with result sets

New in SQL Server 2012 comes an extension to EXECUTE in the form of WITH RESULT SETS. WITH RESULT SETS allows column names and their data types to be changed in the result set of a stored procedure. My first thought with this improvement is that it could be very useful to have when building [...]

New T-SQL features in SQL Server 2012 – OFFSET and FETCH

sql server offset and fetch versus row_number()

Microsoft has decided in SQL Server 2012, that they will modify the ORDER BY clause and do what MySQL has been doing for a long time – providing simple functions for paging result sets. This comes in the form of OFFSET and FETCH. Now, I’m not saying that this was previously not possible in SQL [...]

10 simple tips on improving query and server performance

Ferrari 458 Italia

The following tips do not promise that your database server will magically become blisteringly fast and go like a Ferrari but they are important things to bear in mind and relatively simple to implement either when building your database or if you have an existing performance problem and are looking for ways in which to [...]

New T-SQL features in SQL Server 2012 – CREATE SEQUENCE

create sequence

Continuing on from new T-SQL features of SQL Server 2012, I wanted to explain about the new CREATE SEQUENCE feature. What is CREATE SEQUENCE for? A common feature in table design is to place an auto incrementing number on a field in the form of an IDENTITY column. So this is an easy way of [...]

New T-SQL features in SQL Server 2012 – Conversion Functions

SQL Server 2012 (“Denali”) is nearly here and with all new releases, there are always new features to know about. I am very interested to find out more about the product and my next few posts will talk about some of the new T-SQL features of SQL Server 2012. This first post will cover the [...]

GROUPING SETS performance versus UNION performance

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 [...]