Friday, May 2, 2008

Unexpected SqlException...

On the production servers at the customer I'm currently working for, we had a strange error regarding a new feature in our reporting tools. A strange error, because during the development and test cycle of our release, we hadn't found any issues regarding SQL errors.

The error firing was 'The count aggregate operation cannot take a uniqueidentifier data type as an argument', during the execution of SELECT COUNT(Item.Id) AS ItemCount ... while the datatype of Item.Id was uniqueidentifier.

The only difference between our development, test and production servers is the version of MS SQL Server. While we migrated our dev and test servers to 2005, production was still behind on version 2000. And version 2000 can't run an aggregate operation on a uniqueidentifier, you need to run it with the asterisk instead (like COUNT(*) ).

Fortunately, migration to MS-SQL 2005 is already scheduled to happen soon :)

No comments: