How to copy and paste script text from SSMS to Outlook or Word without garbling it?

删除回忆录丶 提交于 2020-12-06 13:28:05

问题


Say, I have a script nicely formatted in SSMS and it's annotated with all kinds of comments in different languages. But when I copy and paste this nice thingy into Word with syntax highlighted I will get a syntax-highlighted message with those comments garbled, as if reading the source text with one code page and pasting it using another code page. Very nasty kinda bug. Does anyone know how to solve this issue once and for all?

Thank you!

[Update]

alt text

[Solution]

Save → Save with Encoding... → Encoding : Unicode (UTF-8 with signature).

[Related forums]

  • Need a way to set the default encoding for query files in SMSS. by ChrisMay @Microsoft Connect (Go and upvote this issue at Microsoft Connect)
  • SQL Server Management Studio - File Encoding @SqlDev
  • SSMS : Option to set default save as encoding for CSV by AaronBertrand @Microsoft Connect

回答1:


After some tests, I'm still unable to reproduce the issue. And I have no idea why copy-pasting text from one Unicode-compatible to another Unicode-compatible app can give such results.

There are several things you can try:

  1. Inside SSMS, save the script as an Unicode file: SaveSave with Encoding...Encoding : Unicode (UTF-8 with signature). You will then be able to open it probably correctly in Word. The problem is that syntax highlighting will be lost.

  2. Save the script as an Unicode file, than reopen it and copy-paste. Maybe SSMS assume for some reasons that there is some fancy encoding by default, so this will force it to use UTF-8 instead.

  3. Try to paste in different applications (for example the browser). Looking at the first line at your screenshot, I remember once seeing the same problem with some browser renderings described on Wikipedia (can't find the link).

  4. Try copying the same text from Visual Studio (if installed). Copying source code from Visual Studio to Office programs preserve syntax highlighting, so if you observe the same issue, it may come from this syntax highlighting feature.

  5. If nothing works, report the problem to Microsoft Connect, describing precisely the situation so the people at Microsoft will be able to reproduce this issue.



来源:https://stackoverflow.com/questions/3665168/how-to-copy-and-paste-script-text-from-ssms-to-outlook-or-word-without-garbling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!