The importance of being earnest

I’ve been learning and trying out a lot of new things recently and it got me to thinking just how important it is in this business, to continue pushing yourself and adding more strings to your bow. It can be easy to stay within your comfort zone and go with the flow, but there (usually) comes a time when you have to branch out for one reason or another. Stand-ups, Tomatoes and a date(-abase) with Cassandra Over the past week we’ve started doing daily stand-ups at work - still in the early stages but it already feels like I’ve been doing it for longer. [Read More]

Getting started with Cassandra and .NET

Over the past couple of days, I’ve started playing around with Cassandra in an effort to satisfy my curiosity and to see what it’s all about. In terms of databases, SQL Server is my main skill - I first started using it nearly 10 years ago, and will always remember the first book I read cover to cover on it: Inside Microsoft SQL Server 6.5 by Ron Soukup. So Cassandra is a step outside of my comfort zone; something new and a little alien to me…. [Read More]

Validating an SQL query programmatically, with gotcha

If you want to check the validity of a TSQL statement programmatically, you can make use of the SET NOEXEC statement. As this MSDN reference states, SET NOEXEC ON will compile the query but won’t actually execute it. This is ideal (well, nearly….) if perhaps you have a dynamically generated statement that you want to check is valid before executing it. Example time SET NOEXEC ON GO SELECT TOP * FROM sys. [Read More]

The SQL Server MasterClass Experience

SQL Server MasterClass 2010 was a very high quality, one day event presented by Paul S. Randal (Twitter | Blog) and Kimberly L. Tripp (Twitter | Blog) - not that they need any introduction of course. In fact if you don’t know of them, then perhaps you should close down your SSMS window and switch off your machine - after reading my blog of course :). Maybe uninstall SQL Server too… [Read More]

SQL Server XML datatype with CDATA

So today I learnt something new - it turns out the XML datatype in SQL Server does not preserve CDATA sections. e.g. DECLARE @XML XML SET @XML = '<Test><NodeA><![CDATA[Testing cdata section <woop!>]]></NodeA></Test>' SELECT @XML Results ------------------------------------------------------------------ <Test><NodeA>Testing cdata section &lt;woop!&gt;</NodeA></Test> After a quick dig around, I found this MS Connect case. I personally would like to see it accept whatever you pass in without silently altering it, as long as it’s well-formed XML of course. [Read More]

Optimising wildcard prefixed LIKE conditions

Suppose you want to write a query to find all products in your database that have a name beginning with “Long-Sleeve”. You’d more than likely use something like below (examples based on AdventureWorks LT sample database): SELECT name FROM SalesLT.Product WHERE name LIKE 'Long-Sleeve%' This produces a good execution plan, performing an index seek on the nonclustered index that exists on the name column. If you look at the seek operation, you’ll see the query optimiser has done a good job of ensuring an index can be used by looking at the seek predicate: [Read More]

QCon London 2010 Videos

It’s been a couple of months now since QCon London (check out my previous blog post on The QCon London 2010 Experience) and some session videos are starting to make their way out on InfoQ. With a lot of great content, they’re well worth checking out. I’ve re-watched the sessions I attended and enjoyed them as much the second time round as I did the first time. The State of the Art on . [Read More]

The SQLBits VI Experience

I had high expectations about SQLBits VI and it certainly lived up to it! Not only did it have great speakers, who really know their stuff and have an effortless way of getting the information across, but it was also free. So it goes without saying that it was a popular event. There were 4 sessions going on at any one time with a theme of performance and scalability and plenty of choice across DBA, Dev and BI areas. [Read More]

SqlBulkCopy ColumnMappings Mismatch

“The given ColumnMapping does not match up with any column in the source or destination” This error caused me more head-scratching than it should have done today. I was using SqlBulkCopy to bulk insert some data into an SQL Server table from a .NET DataTable, something I’ve done before - it’s not rocket science. But I hit this error upon calling WriteToServer and it took me a while (longer than it should have done really! [Read More]

SQL CAST to VARCHAR without size

What’s the result of this, in SQL Server? SELECT CAST(12345 AS VARCHAR) As you expect, it’s “12345”. How about this? SELECT CAST(1234567890123456789012345678901 AS VARCHAR) You may be expecting it to return “1234567890123456789012345678901” but it will in fact throw an error: Msg 8115, Level 16, State 5, Line 1 Arithmetic overflow error converting numeric to data type varchar. It’s all because a length was not given for the VARCHAR to convert the value to. [Read More]
sql