0

I am trying to copy the result which is a query and trying to indent it the way it should be. But when I copy and paste it in the new window, the query displays in 1 single line instead of multiple lines. I am trying to get it working on sql server 2008.

Here is a sample of my code. It is a stored procedure that is a result.

Create procedure dbo.test @Mypath  nvarchar(max) AS BEGIN Declare @iterator int set @iterator=1 .....

What I want when I copy and paste is

 Create procedure dbo.test @Mypath nvarchar(max) 
 AS 
 BEGIN

 Declare @iterator int 
set @iterator=1

The code is around 1000 lines hence, entering new line is a big task.

Therefore I need a setting that when I copy and paste my result procedure it should display as a procedure in multiple lines .

Any help appreciated.

Tab Alleman
  • 31,483
  • 7
  • 36
  • 52
NancyJoe
  • 41
  • 1
  • 2
  • 5
  • Your question is not clear, at first you say _result_ but it seems like you want to format the code, **not the result**. I don't understand, are looking for a tool to format the code? – Ilyes Jan 08 '18 at 16:55
  • What is your result a result of? – Tab Alleman Jan 08 '18 at 16:55
  • Well, I say result because I use SELECT OBJECT_DEFINITION (OBJECT_ID(N'test.dbo')); to get the stored proc as a result. And hence when I copy and paste the result of this query to another window, it displays the query in 1 single line instead of multiple lines. – NancyJoe Jan 08 '18 at 16:58
  • Do you have to get the stored proc that way, or can you right-click and script it? – Tab Alleman Jan 08 '18 at 18:19
  • I have to get it that way, since it is in a recovery mode. I cannot directly right click and script it, which would have been way easier. – NancyJoe Jan 08 '18 at 18:27

1 Answers1

0

This is an old question but since it still comes up in searches, please refer to:

SSMS Results to Grid - CRLF not preserved in copy/paste - any better techniques?

or

enter image description here