Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pras2007
Posting Yak Master
216 Posts |
Posted - 2009-09-28 : 11:54:22
|
| Hello All,Below I created a computed field in sql now how can I add a defualt value of 0?ALTER TABLE Table ADD [Total_Amount] AS ([Col1] + [Col2])Please advice.Thanks. |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-09-28 : 12:59:47
|
| a default doesn't apply to a computed column. If your expression can be null because either Col1 or Col2 allows Nulls and you want a zero in those cases then use: (coalesce([Col1] + [Col2], 0))Be One with the OptimizerTG |
 |
|
|
|
|
|