When ever I'm using sp_helptext to open stp its create balnk horizontal space in stp. Please let me know how can I remove that existing spce from stp and how can I prevent stp for future.
STP = Stored Procedure? If so not seen that abbreviation before. Maybe its a Stored Template Gallery STP file in Sharepoint though ...
If its a Stored Procedure then sp_HelpText will introduce line breaks for any line that is more than 128 (I think?) characters. If a line is a few more than 128 characters but ends in space(s) then that would give you a blank line. Either way, long lines are going to have (incorrect) line breaks when output using sp_HelpText.
I have no idea why MS haven't fixed this (well, not in SQL2012 at least ...), its been like that for as long as I can remember --- SQL 6.1 probably!
If this matters then script the SProc in SSMS instead.
If the question WAS about Stored Template Gallery STP files in Sharepoint then I have no idea, sorry !!
You could try...
select object_definition(object_id('proc name'))
Then you can copy/paste the results to a query window. This will preserve the formatting of the procedure... unlike sp_hepltext
I believe the 8K character issue happens with the print statement. When you use select and the object_definition function, you get everything. Then you can copy the result column to the clipboard and paste it to a query window. I couldn't find the upper limit for the print statement... but, I'm guessing it's 8000 characters.
Its a limitation of the GRID display in SSMS (and other, similar, tools). Can't remember what the default is, but I think it might be 255 or 8,000; mine is currently set to 65,535 - it will not take a larger value. I almost certainly have SProcs bigger than that
Why sp_HelpText can't just chunk-up the data and SPLIT it into ROWS on actual linebreaks beats me. The only problem then would be individual lines that were longer than 8,000 (or 65,535) characters - which would be much less likely to occur.
In the past I have scripted out the stored procedure using SMS, copy the contents of the query window paste into notepad ++ and use line operations in there to remove the blank lines.
Copy the newly formatted sql and paste it back into SSMS using alter proc