View Full Version : Supid newbe varchar(n) question!


DrZoidberg
12-10-2005, 09:27 AM
What data type should I use if I have no idea how much data will be entered? And is there anyway of avoiding all the trailing white space if I enter, e.g. varchar(50).

Thanks in advance.

Rickster57
12-10-2005, 09:38 AM
Normally a text field allowing for 255 characters is enough. Anything larger would be a comment field.
To avoid "trailing spaces" use the trim statement.

DrZoidberg
12-10-2005, 09:41 AM
thanks for the speedy reply, can you just confirm that basically it's necessary to use the trim statement all the time to avoid the trailing space?

Thanks.

Rickster57
12-10-2005, 09:55 AM
This depends on the data being entered. If a user types in "Whatever" then there won't be any trailing spaces no matter what you set the field length to.
If a user types in "Whatever " then those trailing spaces will be part of the data entry for that record and the trim statement should be used.

Hope this helps.

DrZoidberg
12-10-2005, 12:20 PM
Thanks, I just mistakenly used char(50) instead of varchar(50) and noticed that blank character spacers (amounting to 50) were being inserted. All fixed now, thanks for the help.