Skip to content

Commit bf06795

Browse files
committed
sp_helptext2 fixes
1 parent a392cac commit bf06795

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Modulos/sp.helptext2.sql

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ declare
666666
,@ColName sysname
667667
,@LineNum int
668668
,@WarningLines varchar(max)
669+
,@buffer nvarchar(max)
669670

670671
select
671672
@IsDac = Ep.is_admin_endpoint
@@ -799,7 +800,7 @@ begin
799800
-- iterative over chars
800801
-- IF line break found, print it and starts again.
801802
set @LineNum = 0;
802-
set @WarningLines = '';
803+
set @buffer = '';
803804
WHILE @i < @len
804805
BEGIN
805806
-- Find next linebreak!
@@ -811,10 +812,12 @@ begin
811812
begin
812813
set @LineNum += 1;
813814
-- print entire line!
814-
set @LineLength = @NextLineIndex-@i-1
815+
set @LineLength = @NextLineIndex-@i
815816
set @start = @i;
816817
set @i = @NextLineIndex + 1;
817818

819+
820+
818821
IF @Debug = 1 RAISERROR(' -- LineNum:%d, Length: %d',0,1,@LineNum,@LineLength) with nowait;
819822

820823
if @mode = 'text'
@@ -824,8 +827,13 @@ begin
824827
set @i = @start+@LineLength;
825828
end
826829

827-
828-
print substring(@ObjectDefinition,@start,@LineLength)
830+
if @LineLength <= 0 -- empty line. Add to buffer because print or raiseror add space if print empty line
831+
set @buffer += nchar(13)+nchar(10)
832+
else begin
833+
set @buffer += substring(@ObjectDefinition,@start,@LineLength)
834+
print @buffer
835+
set @buffer = '';
836+
end
829837

830838
if @LineLength > @MaxLineSize -- print limit
831839
begin
@@ -838,6 +846,10 @@ begin
838846

839847
END
840848

849+
-- if buffer contains something, print!
850+
if len(@buffer) > 0
851+
print @buffer;
852+
841853
print ''
842854

843855

0 commit comments

Comments
 (0)