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 |
|
Bertrandkis
Starting Member
8 Posts |
Posted - 2006-03-16 : 06:00:02
|
| Hello folks, I am sending a email from sql server that consists of results of a query and that's working perfect.When I open the text file generated by xp_sendmail in notepad it's OK, but when I open it in MS Word or WordPad, I see garbage characters in form of squares added to the content. Those sqare are unicode spaces equivalent to Nchar(140) or Nchar(0020) in SQL. I tried to replace them using the replace function :declare @foo varchar(8000)set @foo='select top 4 Replace(priMarykey,Nchar(0020),'') as primarykey,Replace(Sitename,Nchar(0020),'') as Sitename,Replace(REgNumber,Nchar(0020),'') as REgNumber,Replace(ContactEmpFirstNames,Nchar(0020),'') as ContactEmp from organisationsite'EXEC master..xp_sendmail @recipients = 'Bertrandk@Holala.co.za', @subject = 'Test mail', @query =@foo,@no_header= 'TRUE', @message='some attachement', @attach_results = 'TRUE' This does not work, the spaces are still in the fileIs there something I can do to correct this?Thanks in anticipation for your help. |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2006-03-16 : 08:25:35
|
| Why do you say "NChar(0020)"? Leading zeros in numeric literals don't have any special meaning in T-SQL, so that's exactly the same as "NChar(20)". U+0014 certainly isn't a space, it's a control character. Perhaps you mean "NChar(0x20)" or equivalently "NChar(32)".Similarly, "NChar(140)": U+008C is another control character -- perhaps here you mean U+00A0 NO-BREAK SPACE ("NChar(0xA0)" or equivalently "NChar(160)"). |
 |
|
|
|
|
|
|
|