Supid newbe varchar(n) question! (1 Viewer)

DrZoidberg

Registered User.
Local time
Today, 19:24
Joined
Jan 12, 2005
Messages
14
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

Registered User.
Local time
Today, 11:24
Joined
Nov 7, 2005
Messages
431
Data type

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

Registered User.
Local time
Today, 19:24
Joined
Jan 12, 2005
Messages
14
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

Registered User.
Local time
Today, 11:24
Joined
Nov 7, 2005
Messages
431
Trailing spaces

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

Registered User.
Local time
Today, 19:24
Joined
Jan 12, 2005
Messages
14
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.
 

Users who are viewing this thread

Top Bottom