6

I use OneNote to keep all usefull info for my work, including SQL queries.

So I copy paste them between OneNote and Microsoft SSMS (SQL Server Management Studio)

When I do so, I have often wrong characters in SSMS that I must remove manually.

In the other way around (from SSMS to OneNote), the nice color SQL formatting is lost (I can put it into MS Word and then OneNote and it works but it is not very practical).

Helodia
  • 108
  • 2
  • 9
  • I did not find a very usefull way to handle my problem. – Helodia Feb 05 '14 at 10:06
  • 1
    I achieved however to get rid of hidden characters using NotePad++ with HexEditor plugin : find and replace character "a0" and replace with "20" (space) – Helodia Feb 05 '14 at 10:07

7 Answers7

5

Copy the text from SSMS to Microsoft word. Then copy the formatted text from MS Word to OneNote. Works fine.

Reggie
  • 51
  • 1
  • 2
  • This is what I'm doing at the moment. Painful but it works. Shame it's required though :( – Ian Yates Jun 23 '15 at 02:09
  • hi @Reggie, brilliant. But I would say that you can copy-paste from ssms to word then copy-paste from word to your application, whatever it is. – Andy K Feb 08 '18 at 08:50
1

This is the result of MS Office's "helpful" "smart quotes" and similar formatting.

  1. If possible turn off smart quotes and the like in OneNote
  2. Copy from OneNote, paste into a plain-text editor, then copy from there & paste into SSMS. You may still get some invalid characters.

What it really boils down to is that programs like Word and OneNote are often counter-productive for technical content that requires specific characters because they are designed for non-technical writing. You may wish to consider switching to another note organizational tool that doesn't muck with formatting like this.

alroc
  • 27,574
  • 6
  • 51
  • 97
1

I was having the same issue and I was using NoteHighlight but I does not work in ON2013. I now use OneNote Gem but as someone else pointed out it is not free but inexpensive $28.00 US. You can highlight the the queries in SSMS, copy and then select Click on "Paste Rich Text" in the GEM Edit menu and it will keep the formatting including the color, to paste it back into SSMS without the unrecognized characters, highlight the text in OneNote then form the GEN Edit Menu Click on "Copy Plain Text" and paste back into SSMS

skull0752
  • 11
  • 1
0

I can't help on pasting into SSMS but you have a couple of options for the syntax highlighting:

  1. This add-in doesn't work for me, but I have ON 2013 64bit, maybe it'll work in 32bit or 2010, clearly it has worked for some people in the past.

  2. OneNote Gem has a syntax highlight option. I find their UI a bit cluttered and it is annoying to have to paste into a special window, but it does work.

Darren Beale
  • 753
  • 1
  • 9
  • 24
0

For the SSMS to OneNote issue, I know this answer is really only a variant of your Word workaround, but I open up SQL files in Visual Studio prior to copying into OneNote. In that way the format can be copied too. If you can consider that in your workflow then I think it's a better workaround than Word, as of course you can also edit the files in VS. Note that you'll need the VS Productivity Power Tools plug-in to achieve the format copy. e.g. for VS2013 go to:

RBH
  • 1
0

A possible workaround is to open the notebook in the web client and paste from SSMS to the onenote web app. That works directly

0

I wrote this little addin for this exact issue

https://github.com/SamuelOConnor/RichPaste

Osie J O'Connor
  • 421
  • 7
  • 14