Code Example – MSSQL Test Update

I posted, in june of last year, about some very useful MSSQL tests that make development and the promotion process we use here at Broadcom easier. One of the tests was not entirely correct, and id like to make a quick substitution (although i wont be replacing the previous entry because it sort of works too).

Does a table have a field already?

IF EXISTS (SELECT Coalesce(Col_length('dbo.T_Table', 'FieldName'), 0))
GO

should be

Does a table have a field already?

IF EXISTS (SELECT 1 WHERE Col_length('dbo.T_Table', 'FieldName') > 0)
GO

sorry about the mixup. This new one is much simpler to read share with your friends and actually works well.