Using conditionals before adding columns to a table in SQL server
Using conditionals before adding columns to a table in SQL server Working with databases is not as easy as it looks like, specially if you are working with production databases. When a database is production you need to be very careful with the changes you make, adding, removing tables, columns, changing data, etc. Once a database is in production you use incremental scripts in order to push new updates into it. These incremental scripts need to handle everything and they do not have to have any errors and must be able to run multiple times if it is needed. One thing I keep seeing in lots of incremental scripts are the lack of verification before they are executed. The other day I asked one of my developers to add one column to a table and also to write the respective incremental script and UI controller. This is what I got: ALTER TABLE [table] ADD [column_name] VARCHAR ( 10 ) DEFAULT [defaultvalue] ; There are a couple of things i do not like about this script but one of them wa...