Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL OBJECT_DEFINITION returns stored procedure text for editing

Posted on 2016-07-26
9
Medium Priority
?
79 Views
Last Modified: 2016-07-27
I've been using OBJECT_DEFINITION for a long time now, and it has been outputting text of stored procedures to the results grid in a nice and readable format (just like sp_helptext).

Yesterday, I upgraded my machine to Windows 10, and had to reinstall SQL Server (management studio). Now all of a sudden OBJECT_DEFINITION is outputting the entire store procedure text in one line, completely unreadable. How do I make it continue to return text to the results grid in a readable format like sp_helptext.

Extra Details
I have a stored procedure I wrote called "sp_prepareSP" which uses OBJECT_DEFINITION to retrieve the stored procedure text. It then appends text before and after the returned text. Things like "IF EXISTS(...) DROP PROCEDURE", and other things like at the end "GRANT EXECUTE ON ...".
0
Comment
Question by:pzozulka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 25

Expert Comment

by:chaau
ID: 41730489
It works for me. What version of SSMS you have installed?
0
 
LVL 8

Author Comment

by:pzozulka
ID: 41730510
2016. Had 2014 before reinstalled ssms.
0
 
LVL 25

Expert Comment

by:chaau
ID: 41730517
Do you use "results to grid" or "results to text"?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 8

Author Comment

by:pzozulka
ID: 41730526
Only results to grid. I need this to work using grid.
0
 
LVL 25

Expert Comment

by:chaau
ID: 41730547
I think it still should be fine. What happens when you select it and then paste it to a text editor? The difference between the OBJECT_DEFINITION and sp_helptext is that the former returns a text blob in a single row, and the latter is returns a table with each line in a row:
ssmsI have got ssms2014 - they release new products too fast for me to test them all
0
 
LVL 8

Author Comment

by:pzozulka
ID: 41730548
When I paste it into the query window it shows up as a single line.
0
 
LVL 25

Expert Comment

by:chaau
ID: 41730556
It must be a bug in ssms2016 then.
0
 
LVL 25

Accepted Solution

by:
chaau earned 2000 total points
ID: 41730560
No, it is not a bug. It is a feature.
Check this article out. They now have a setting "Retain CR/LF on copy or save". Try it:
CRLF
0
 
LVL 8

Author Comment

by:pzozulka
ID: 41731783
That worked. Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question