0

In my SQL Server 2014 Management Studio I am facing indentation issue. Like if I create a stored-procedure with proper indentation like tabs, spaces etc.. and if I again check the sp then I see no indentation which I gave while creating the procedures.

Created with proper spacing etc...

enter image description here

What I get after rechecking-

enter image description here

Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
Ghanshyam Singh
  • 1,361
  • 2
  • 15
  • 27
  • Yes but its hard to put text with proper indentation – Ghanshyam Singh Apr 30 '20 at 09:21
  • And what is the problem with that? The query should still work, or ist there a problem? Your indentation is just one way how to do it but that does not need to be the indentation of how the SQL stores the queries. Why is it relevant in your case that this indentation is retained when stored in the database? – t.niese Apr 30 '20 at 09:23
  • Yes but the issue is with my SSMS only. If i check in other system it shows correctly. – Ghanshyam Singh Apr 30 '20 at 09:28
  • 1
    Might be related to [Why is SSMS altering my stored procedures (re-formatting, changing exec to EXECUTE, etc.)](https://stackoverflow.com/questions/48067013/why-is-ssms-altering-my-stored-procedures-re-formatting-changing-exec-to-execu) – t.niese Apr 30 '20 at 09:37

1 Answers1

2

When you execute sp_helptext in SSMS:

exec sp_helptext 'YourSpName'

try setting output type to "Results to Text" instead of "Results to Grid".

You can use the shortcut CTRL+T for this or you can enable it from menu Query/Results To/Results To Grid.

This should preserve indentation.

Andrea
  • 11,801
  • 17
  • 65
  • 72