Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSMS - Add a custom button to toggle retaining CR/LF in output

I'm using SSMS v17 and am hoping this is somehow doable.

In my SQL Server DB, I have many tables that have VARCHAR fields that have, within them, CR/LF characters (multi-line text).

I know there is the setting in Tools > Options > Query Results > SQL Server > Results To Grid for Retain CR/LF on copy or save and I find myself often having to toggle that on / off since, if I always leave it on, I can get bad outcomes when I try and copy from the grid into Excel if there are CR/LF characters, but, other times, I just want the data from a specific row and want to copy that VARCHAR with its included line-breaks, so then I need to toggle it back on, otherwise, I end up getting the cell's value as one, long line (line-feeds are removed).

So, the solution I'd love (but I'm VERY open to other suggestions if there are any) is to have a custom toolbar button for that specific command so I can toggle it much more easily than having to go into the menu bar each time.

My challenge is that I'm not finding that command in the list when I try and customize the toolbar. Does it exist or is there another way to associate a toggle-button to that command? Or, as I saidm I'm very open to other suggestions if anyone has any.

Thanks!!

like image 868
John Bustos Avatar asked Sep 04 '18 17:09

John Bustos


1 Answers

SSMS Boost has that functionality. Copy cell data from Results Grid 1:1 (preserving line breaks)

SSMSBoost introduces "Copy current cell 1:1" command:

select cell you want to view/copy, open context menu -> "Copy current cell 1:1" and full data will be copied to clipboard - all bytes and without any modifications.

And the second one is: Copy Results Grid data to Excel (as xml Spreadsheet)


SSMS Tools Pack also has similar capability Feature: Export To Excel:

This feature does not require Excel to be installed and creates a fully functional XLSX Excel file. Export all result sets, one or multiple tables or a whole database to Excel.

Saving the best for last, the characters like newlines and tabs are fully preserved and properly exported into correct cells.

like image 78
Lukasz Szozda Avatar answered Oct 23 '22 17:10

Lukasz Szozda