SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Insert Null values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

learzbu
Starting Member

26 Posts

Posted - 07/25/2013 :  04:48:11  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 07/25/2013 :  04:58:59  Show Profile  Reply with Quote
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

India
22754 Posts

Posted - 07/28/2013 :  09:36:49  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000