Page 1 of 1

Lengthing string field

PostPosted: Thu Apr 18, 2013 2:15 pm
by BRobinsonS
Creating a new table I left a string field too short (25 characters). Now I need 30 characters.
Is there a way to lengthen the field using DBPro or Sql ?
Especially if there is data in this field.

Re: Lengthing string field

PostPosted: Thu Apr 18, 2013 3:10 pm
by Neosoft Support
Try this on a copy of the database first!

You should be able to increase the size of the field with the following SQL statement:

ALTER TABLE tablename ALTER COLUMN fieldname varchar(30)

Re: Lengthing string field

PostPosted: Thu Apr 18, 2013 6:29 pm
by BRobinsonS
It works. Thank you.

Now, I do have a list box that lists the fields of the table and a subroutine which refreshes the list when I add Field or drop a field which works.

It shows the field length type and length e.g. bizname string(50), but after using the SQL command and have the field list refresh it doesn't show the new field length e.g. bizname string(55) unless I close and re-open the Database.

Any thoughts?

Re: Lengthing string field

PostPosted: Fri Apr 19, 2013 10:42 am
by Neosoft Support
I don't know. Probably, the field information reported reflects the condition of the table when it was opened. Since the field's properties were altered via SQL, the database client doesn't know that field information has changed. You could try dbpRefresh, otherwise you will have to close and re-open the table. You shouldn't need to re-open the whole database - just the table.

Re: Lengthing string field

PostPosted: Sat Apr 20, 2013 7:08 am
by BRobinsonS
Closing and opening the table worked.

Thanks again.