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
 How to change the default values

Author  Topic 

poornima
Starting Member

32 Posts

Posted - 2006-11-13 : 02:11:13
The columns fro which we do not enter any values.Fro eg in my table i did not insert any values to Balance col,in my table.
In SQL 2005,management studio,when i said modify table and changed the default to 0 from NULL and also unchecked the checkbox saying Allow Nulls.

I did the above changes and said save.It gave an error saying

'AccountsBalance' table
- Unable to modify table.
Cannot insert the value NULL into column 'Balance', table 'AccountBalanceSheet.dbo.Tmp_AccountsBalance'; column does not allow nulls. INSERT fails.
The statement has been terminated.

Plz help

Poornima

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-13 : 02:14:02
The default value only is for newly created records AFTER the default is set.
Do an UPDATE first!

UPDATE YourTable SET Balance = 0 WHERE Balance IS NULL

Now alter your table.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

poornima
Starting Member

32 Posts

Posted - 2006-11-13 : 02:46:11
Thank you Peter
Go to Top of Page
   

- Advertisement -