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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 null and computed column

Author  Topic 

longinos
Starting Member

11 Posts

Posted - 2007-10-01 : 19:45:43
how do you change the allow null on a column to be 0,
so instead of having null when empty, it would be 0,
I tried default value or binding to 0 to -1, and to 1
and in 0 or -1, it stays null, in 1 it puts the 1
for example if is quantity, it puts as if I would have 1 quantity,
so it's either null, or whathever number I put visides -1 or 0
how can I make it be 0 as defult?
I'm using it to add and substract with computed column, formula;
and the problem is that if it's the first time it's used it does not add or substract, becsause it does not add null with a number, if it has 0 than it works,
whata I had to do is add it manually, but of course it doesn't suppoesed to be that way
any suggestions will be appriciated:

longinos
Starting Member

11 Posts

Posted - 2007-10-01 : 21:30:27
Sorry, I found the solution, it was very easy,
I was confuse thinking that the properties of the column:"default value or binding" was the same as
default vale, which I'm still confuse, but at least it's solutioned,
sql is too easy that confuses me
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-02 : 04:16:15
You also need to set the column to NOT NULL - otherwise it will still be possible to explicitly Insert or Update the column to NULL

Kristen
Go to Top of Page
   

- Advertisement -