Link to home
Start Free TrialLog in
Avatar of Jimbo99999
Jimbo99999Flag for United States of America

asked on

SQL Server 2005 Allow Nulls = False

Good Day Experts

I am in a bit of a quandry here.  I have a SQL Server 2005 table that has 234 fields.  All of the fields have the Allow Nulls property set to false.  I will only need to send data to about 20 fields at the most.  Short of writing ' ' to each of the fields I am not sending data to, is there anything I can dynamically do in the query that would do that for me so I don't have to manually for 200+ fields?

Thanks,
jimbo99999
Avatar of Lee
Lee
Flag of United Kingdom of Great Britain and Northern Ireland image

If possible you could alter the table definition and default the fields to ''

Failing that there isn't an easy way that I know of. Each field would need to be explicitly set to '' otherwise it will complain.

Lee
Without knowing more... Just write an update statement on those 234 fields some that separates them from the other ones:

Update t
Set clientid= 'x'
From table1 t
Where t.unique_for_234_rows = 'i'
Oops I misread not 234 but 20
Why not set the columns to allow NULL?  Isn't that truly the easiest option?

Also, You might want to consider breaking that 234 column table into multiple tables.  That way, you could have the 20 required columns in a Master table and put the other columns, organized into logical groupings, into other tables.

You can set default values for the other columns or if they can be null, just remove the not null requirement
SOLUTION
Avatar of chandrasekar1
chandrasekar1
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks jimbo99999, have a nice day :)