Question : How do I remove special characters in a query?

This is a 2 part question.
1) I am using Visual Studio as well as my co-worker. We look at a table on his PC and it shows special characters (don't knowwhat they are... just 2 little squares). I pull the same query on mine but it doesn't display them. How do I enable my pc to see these special charaters?

2) These characters are in a MSSQL database in a text field, how would I remove these characters?

I tried:
SELECT  REPLACE(COLUMNNAME, '.', ' ') AS Expr1
FROM     VW__TABLE
WHERE  (COLUMNNAMEIS NOT NULL)

But I receive an error:" Argument data type text is invalid for argument 1 of replace function".  I was thinking that this was because it is not a VARCHAR type data field.

Thanks

Answer : How do I remove special characters in a query?

Squares appear usually for
* characters not available in the code page / font
* carriage return + newline, if displayed in a non-multiline edit field.

The grid view is a non-multiline edit field. If you have the same settings (regional setting, OS language, code page aso.), you should see the same on both Visual Studio grid views.

For replacing, you need to convert to nvarchar (Unicode) or varchar (8bit chars, depening on your code page):

select replace(cast(columnname as varchar(4000)), char(13)+char(10)', ' ')
from    VW__TABLE

where columnname like '%'+char(13)+char(10)+'%';



Random Solutions  
 
programming4us programming4us