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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra trailing spaces from MSSQL 1

Status
Not open for further replies.

budjo

Programmer
Mar 4, 2004
19
PH
hello .. I have a database running on MS SQL 2000 , im loading data into a dropdown list , or a datagrid .. using sqldataapater with the following sql command :
"select * from category"
catcode = int 4 - primary code
catdesc = char 100

once loaded on a datagrid or combo box , ive noticed i get trailing spaces at the end of all my catdesc,

populating the combobox would result in the last part of the record being displayed ..
Original Record : " Computer Parts"
Displayed Record on the dropdown ; "uter Parts"

but if you click down the drop down list , you would see the correct data , so it is only having problem when displaying the selected item .. any suggestion would be highly appreciated .. thanks ...
 
The database column is CHAR(100) ??

If so, SQL Server treats those column types as fixed-width columns, and will space-extend them. You'll need to do one of the following:
1. Change the column type to varchar(100)
2. Use RTRIM() in your select statement:
[tab][tab]SELECT RTRIM(catdesc) AS CatDesc
3. Use .Trim() on your string variables in your code

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
i see ..tnx man .. highly appreciated ..will do that .. God Bless ..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top