New sample database – AdventureWorks light

Microsoft have released a new sample database for SQL Server 2005 which is much simpler than AdventureWorks. It’s still based on the same scenario, and it still (frustratingly) uses singular table-names (like Person, not People), but this is certainly going to be useful for all kinds of demonstrations. It really helps to have a model that is easy to understand, and this database, with far fewer tables, is much easier to get your head around. I will probably start using this in the user-group, and any other times when I want to demonstrate a piece of functionality. Download it from … Continue reading New sample database – AdventureWorks light

Coalesce is not the answer to string concatentation in T-SQL

I’ve seen many posts over the years about using the COALESCE function to get string concatenation working in T-SQL. This is one of the examples here (borrowed from Readifarian Marc Ridey). DECLARE @categories varchar(200)SET @categories = NULL SELECT @categories = COALESCE(@categories + ‘,’,”) + NameFROM Production.ProductCategory SELECT @categories This query can be quite effective, but care needs to be taken, and the use of COALESCE should be properly understood. COALESCE is the version of ISNULL which can take more than two parameters. It returns the first thing in the list of parameters which is not null. So really it has … Continue reading Coalesce is not the answer to string concatentation in T-SQL