var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Removing Junk Characters
i have a table and one of the column have junk characters in it,how can i remove the junk characters?.
Eg : Employee
how can i remove Junk characters and get only Enames from aboue table.
DECLARE @ename VARCHAR(20)
SET @Ename = 'a�'
SELECT REPLACE(@Ename, '�', '')
With kind regards . . . . . SQL Server 2000/2005/2012
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
You may need to determine the value that the character is before the REPLACE can be effective. You can use something like this to get that value:
From an inspection of the values displayed and a little knowledge of haxadecimal or an ASCII chart, you can use the REPLACE function. For example, suppose the values displayed are: 0x613F
declare @WeirdText varchar(20) = 'a�'
select cast(@WeirdText as varbinary(100))
The 61 is the lower case 'a' and the 3F (hex) has a decimal value of 63.
This would remove the odd character. Be aware that there may be multiple different weirdo characters in your string so you may need to iterate through this process.
select REPLACE(@WeirdText, CHAR(63), '')
There's also the ASCII() function in SQL server
Last edited by gvee; 03-16-12 at 19:59.
If this is an NVACHAR field, you may need to use the UNICODE() function. Can't be sure, since the original datatype, and/or code page is not supplied.