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
 Database Design and Application Architecture
 Insert Null values

Author  Topic 

learzbu
Starting Member

27 Posts

Posted - 2013-07-25 : 04:48:11
Hi,

I'm trying to update to a table that contains almost 50 NOT NULL columns, but I only need to enter values in 8 fields. The front end application auto generates a space field ' ' to enter blank values into these empty columns. I'm trying to auto generate a script that will update the tables with the values that I need. Can I run some kind of loop that will enter a space ' ' into any column I leave blank? or do I need to enter this space manually?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-25 : 04:58:59
if they're NOT NULL fields what you can do is attach a default constraint on them to make default value as ''. then include only required columns in your update others will get '' as value by default. Once your update is over you may revert it to how it was before by changing default constraints

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2013-07-28 : 09:36:49
Also note that passing space for some columns will be treated and stored differently. Refer this link http://beyondrelational.com/modules/2/blogs/70/posts/10841/empty-string-and-default-values.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -