Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Blank characters being inserted into SQL Table

Author  Topic 

try.test.abc
Starting Member

5 Posts

Posted - 2010-07-31 : 01:15:34
Hello,
I am Working on a Database Application. Database is same for all client. but for One client database there are extra blanks on the end of the field for string Column. AS there is no space at the end of field so we code earlier according to that.. This causes Problem in comparing string.

for example Table1 has a Following data


|-----------------------------|
ID | Person_Name (Char(5))
|-----------------------------|
| 1 ABC |
| 2 DEF |
| 3 GHI |
|-----------------------------|

SELECT * from Table1 Where Person_Name='ABC'


It results NULL as Value stored in Table is 'ABC '
this extra space is Char(160)   character..

I try to remove these character by using UPDATE Query

UPDATE Table1 SET Person_Name=Replace(Person_Name,char(160),'')

it update for a while.. then again space appear..

I am surprise form where these Extra space is inserted?? as this is for one database Only. as all the database has same structure.


Is there any Property of Database which is causing this??

Please Help...

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2010-07-31 : 01:40:08
Odds are it's still the field being passed to the db incorrectly, even though you think you are removing the unwanted charectors. Make sure it's a space field and not a carriage return or something else. Check the front end application code again, it seems like that would be where the error is happening.





Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

try.test.abc
Starting Member

5 Posts

Posted - 2010-07-31 : 01:46:29
i m passing all the string field by trimming..
and it is working with my local database..
this is only problem for specific one DB..
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-07-31 : 02:20:38
"i m passing all the string field by trimming.."

Trim won't remove CHAR(160) though ...

CHAR(160) is the value for a Space - CHAR(32) - with the high bit set - i.e. CHAR(32+128) - so looks like something is setting the high bit. Perhaps a word processor that uses that "trick" for a space that has been wordwrapped, or a non-breaking space, or somesuch, and the user has cut & pasted from that? - which would account for why it is only one client.
Go to Top of Page

try.test.abc
Starting Member

5 Posts

Posted - 2010-07-31 : 02:49:52

let me check how client enters data..

Thanks for reply.
Go to Top of Page
   

- Advertisement -