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
 General SQL Server Forums
 New to SQL Server Programming
 update does not work!

Author  Topic 

maevr
Posting Yak Master

169 Posts

Posted - 2008-02-11 : 02:24:57
I need to remove all white space i a column in order to succefully convert to int, but it does not seem to work in just this table.

I cannot understand why! I have done this a thousand times before!

I use:
update table1 set col1 = replace(col1, ' ', '')

datatype is varchar(10) not null

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-11 : 02:28:00
looks perfectly alright to me ?

What do you mean it does not work ? The update ? or the convert to int ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

maevr
Posting Yak Master

169 Posts

Posted - 2008-02-11 : 02:48:12
The update does not work.
When I run the query everything looks alright but when I check the value it shows the old value.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-11 : 02:55:15
perhaps it is not space but unprintable character ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

maevr
Posting Yak Master

169 Posts

Posted - 2008-02-11 : 03:00:27
How can I check this?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-11 : 03:24:19
use the Ascii() function to display the ascii code


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-11 : 03:36:50
update table1 set col1 = replace(col1, ' ', ''),
col1 = replace(col1, CHAR(160), ''),
col1 = replace(col1, CHAR(13), ''),
col1 = replace(col1, CHAR(10), '')






E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

maevr
Posting Yak Master

169 Posts

Posted - 2008-02-11 : 04:22:07
It worked, thanks for your help.
Go to Top of Page
   

- Advertisement -