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.
Author |
Topic |
inbs
Aged Yak Warrior
860 Posts |
Posted - 2013-10-08 : 08:38:39
|
hi,how do i remove all the irreular signslike #-OLD~*my column:DB54-0006#2-OLDN427722#1-OLD16GB0141#7-OLDM02025006A~1 |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2013-10-08 : 09:05:54
|
SELECT REPLACE(REPLACE(REPLACE(REPLACE(field,'#',''),'-OLD',''),'~',''),'*','') FROM Table |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-08 : 09:38:50
|
quote: Originally posted by inbs hi,how do i remove all the irreular signslike #-OLD~*my column:DB54-0006#2-OLDN427722#1-OLD16GB0141#7-OLDM02025006A~1
do you've a full list or do you need to remove all special characters?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
inbs
Aged Yak Warrior
860 Posts |
Posted - 2013-10-08 : 13:11:54
|
the REPLACE function it is good but not enough.see the next examplei have this value 14GC7310#10~01and i want to get 14GC7310140713#01 ---> 140713N485083#01--->N485083N485083#01-OLD-->N485083i want to clean all characters after the first irrgular character |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-08 : 13:23:39
|
quote: Originally posted by inbs the REPLACE function it is good but not enough.see the next examplei have this value 14GC7310#10~01and i want to get 14GC7310140713#01 ---> 140713N485083#01--->N485083N485083#01-OLD-->N485083i want to clean all characters after the first irrgular character
SELECT LEFT(Field,CASE WHEN PATINDEX('%[^0-9A-Za-z]%',Field)>0 THEN PATINDEX('%[^0-9A-Za-z]%',Field)-1 ELSE LEN(Field) END)FROM Table ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|