Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting default for almost all columns in a table?
Message
From
14/07/2012 12:11:22
 
 
To
14/07/2012 11:58:56
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01548548
Message ID:
01548590
Views:
49
>>In my opinion it is more than OK. I prefer no NULLs (unless a compelling reason to do so) and all columns with defaults ( makes inserts a lot easier as well )
I did that in my VFP days, but with .NET I've stopped using the defaults in the SQL table and I set the default values in the code.
When I add a row, I call a function that loops thru all the columns in the datatable, and based on the type, sets the default values in the datatable row.


Why?

A. I had some problems a few times with the constraints created by the default values when handling the tables in SQL
B. I kept forgetting to do it when I added columns and sometimes I put the wrong values in.

The function never misses a column or sets the default incorrectly.
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform