Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra Spaces in the database

Status
Not open for further replies.

MrColdFusion

Programmer
Mar 8, 2000
1
US
After inserting into a char field I have spaces padding out the field... How can I turn this off...

When I do a query to see if test = field and the field contains test but it is a char(10) then it will not be true.

HELLLLPPPPP!!! X-)

Thanks,
Mr.ColdFusion [sig][/sig]
 
can you use a varchar field? [sig]<p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
[/sig]
 
You can use the rtrim and ltrim functions in code to do the test. Or, to turn it off, use a varchar(10) data type. varchar won't of course, give you padding.

To trim for a code test, do this:

If RTrim(LTrim(column)) = @field_i_am_testing
Begin
-- whatever...
End

Tom [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top