I tend to use defaults for a couple of reasons.
On a column like "DateCreated", use a default and use "default" in insert statements. Having "default" in there helps document the column since that means the column name can be found in source control docs in procs that insert to that table.
On other columns that are almost always initially a certain value, it can be useful to have that as a default. If the default value is more than a few characters, I'm lazy, so setting it as a default means I don't have to include it in all of my procs. The ones that will override the value have it, the others don't, and I save myself a few keystrokes on those ones. Not necessarily a good idea, but I do it anyway.
On columns with complex initial values, using a UDF as the default can save coding and make for more maintainability. For example, if a column referencing a separate table could have one of five initial values, based on moderately complex business rules, a UDF might be able to figure out which value it should be, and then insert procs can just have "default" in them and the UDF will fill in the default. "If an order is started on a Saturday, it starts with value X, unless it's the day after a holiday, in which case it's Y, whereas if an order is started on a Monday in the summer, it has value A, but the rest of the summer it's value B, and in the winter Fridays are M, everything else is S, unless it's a holiday, which is always Q regardless of time of year or day of week". Something like that would be a major pain to have to build into every proc that creates a record in the orders table, but a UDF based on a calendar table and a lookup table would be able to handle it with ease. Of course, having such built into a business layer might be better, if you can absolutely guarantee that every application that accesses the database will always have the current business layer. (That can be a problem if some salespeople use laptops for order entry, and aren't always connected to the network when they do so.)
So, your mileage may vary, but I find defaults useful.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon