May 1, 2009 at 4:20 am
My excel data contains following information (myexcel.xls)
OwnerName FatherName RationNO
Thirupathi Vittal Wap 182501100164
Thirupathi Vittal NULL
RAM VIJAY Wap 182501100167
RAM VIJAY NULL
Im importing excel data to sql server database (Sample Table)
after importing excel data into sql server im getting spaces before fathername
and after fathername
when im using ltrim or rtrim it is not working
Then How to remove the spaces
Can u give me a better solution to solve my problem?
May 1, 2009 at 4:31 am
First of all you have to make sure that it is space. It could be another charcter such as tab or a control character that can not be seen. In fact because ltrim didn’t trim it, I’m sure that this is not a space. Try running this statement to check what it is:
select ascii(substring(fathername,1,1)) from MyTable
After you’ll get the ASCII code, you can check what character it is.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
May 1, 2009 at 5:23 am
As you wrote in the other thread the "spaces" are CHAR(0) and CHAR(10). So use REPLACE to remove them.
Greets
Flo
May 1, 2009 at 2:32 pm
I usually do a replace() on char 10, 13, 20, 0 or whatever needs to be done.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply