Adjusting VARCHAR Field length

We have a custom field that is 255 characters. I need to adjust it to be 2000 characters.
I know where to do it in Custom Field Maintenance and I know how to regenerate the database after.

However I’ve been burned by this screen before when changing field types from say string to boolean, the application threw all kinds of errors on screens with the field in question.

If I just want to adjust the varchar size can I do that on that screen and regenerate?

Or do I have to delete the field, regenerate, remake the field, and then regenerate? (I’d rather not do this if I don’t have to, it’s kind of a pain.)

You can change it in UD Column Maint and regen, but you will likely need to remove a constraint.

I found that I was unable to change the size of the field and regenerate. There was an error when running generate. This might be due to the fact that there is already data in the field.

You can still change the field size.

This is a bit of a hack, so make sure you backup the DB before hand.

Export the data via a BAQ.

Make the changes Aaron mentioned.

Import the data (one field) via DMT.

What was the error? If it was the constraint that is normal, you need to remove the constraint.

Yes it appears to be the constraint error. How do you remove the constraint?

The object 'DF_PartPlant_UD_GPMReviewComments_c' is dependent on column 'GPMReviewComments_c'.
ALTER TABLE ALTER COLUMN GPMReviewComments_c failed because one or more objects access this column.
ALTER TABLE [Erp].[PartPlant_UD] ALTER COLUMN [GPMReviewComments_c] nvarchar(max)  NOT NULL  
EXEC Ice.DropColumn N'Erp', N'PartPlant_UD', N'GPMReviewComments_c', 1
ALTER TABLE [Erp].[PartPlant_UD] ADD CONSTRAINT [DF_PartPlant_UD_GPMReviewComments_c] DEFAULT '' FOR [GPMReviewComments_c]

Did you check the link Aaron posted?

You can visually remove the constraint with the SQL server MGMT tool.

or you can do so in sql.

ALTER TABLE [Erp].[PartPlant_UD] DROP CONSTRAINT DF_PartPlant_UD_GPMReviewComments_c;

If you do everything correctly. You will not need to reimport the data. That is just incase the column gets messed up.

I literally didn’t know that if you click on the post it expands. His post makes so much more sense now.

1 Like

retry and update with what happens.