August 27, 2018 by Kenneth Fisher
By the way, if you haven’t seen any of Bert’s vlog posts before they are well done and highly entertaining. Anyway, Bert was having difficulties displaying particularly long text strings. Now I’ve had this problem before myself and used several of the solutions he did and learned a few new ones. However, I did know a handy little setting that solved one of his problems. Keeping carriage returns and line feeds when copying data out of a grid output.
When you put formatted text into a variable:
-- Setup DECLARE @MyString varchar(8000); SET @MyString = 'SELECT * FROM sys.databases WHERE database_id = 4' ; SELECT @MyString;
SSMS Settings to the rescue!
Now, you do need to be aware that the settings Tools -> Options are just for new query windows. If you want to change the settings for an already existing window then either go to Query -> Query Options or right click in the window and go to Query Options from there.
Either way, once you are done and re-run your script you get this when you copy and paste:
Much better right?