It’s one of those things that always aggravated me but not really enough to complain about. When you run a query to grid in SSMS then copy and paste the value to a query window it stripped the carriage return/line feed.
-- Setup code CREATE TABLE GridTest (String varchar(50)) GO INSERT INTO GridTest VALUES ('Line Broken In String'), ('Line'+char(13)+'Broken'+char(13)+'With'+char(13)+'char(13)'), ('Line'+char(10)+'Broken'+char(10)+'With'+char(10)+'char(10)') GO
Note that I’m testing with a string broken up by hitting enter, a string where I manually add char(13) and a string where I manually add char(10).
Run a SELECT * to a grid output.
In SSMS 2008 R2 (and prior) when I copy the values and paste them into a query window (or notepad etc) and I get this:
Line Broken In String Line Broken With char(13) Line Broken With char(10)
Not a big deal you might say, but when you are looking at sys.sql_modules or sys.dm_exec_query_text and copy and paste out code for a stored procedure, a view or even a relatively simple query it can be very aggravating.
Well when I copy and paste out of SSMS for SQL 2012 I get this.
Line Broken In String Line Broken With char(13) Line Broken With char(10)
Woo hoo! All three of them display the carriage returns and line feeds. It may be a minor change but you have no idea how much I appreciate it. I should probably note that when I tried it by adding a CHAR(13) and a CHAR(10) I got the following (which is also rather aggravating but over all I think I’m still happier).
Line Broken With char(13) and char(10)
Filed under: Microsoft SQL Server, SQLServerPedia Syndication, SSMS Tagged: microsoft sql server, SSMS