Suppose I have a table called SerialNumbers which has columns:
- Id
(int) - SerialNumber
(nvarchar) - IsValid
(bit) - ToBeUsedBy
(DateTime)
Currently this table is being used by numerous different applications. Now we have a requirement to add a new column named CurrentlyAt (int) which will always have a default value of 1. I have gone ahead and added the column with a default value of 1.
So my question is, would I now have to change all my previous insert queries to include the new column or would it add a value by default if I didn't add it to the old insert statements?
default). Fortunately forINSERTstatements the approach that's not useless prevails, and you're not required to mention the column at all.CREATE TABLE T(ID INT, X BIT NULL DEFAULT 0); INSERT T(ID) VALUES (1); SELECT * FROM T. You may be thinking of ORMs like Entity Framework who may get confused and retrieve the column for purposes of generating a statement, but without retrieving the default from the constraint (and so unwittingly pass an explicitNULLwhen the user did not intend it).