Dynamic SQL getting cut off with PRINT STATEMENT

I have a long stored procedure (dynamic sql) that I am trying to print out so I can debug it.  The SQL is contained in this variable - @sSQL.

When I run this PRINT statement, it keeps getting cut off:


How can I overcome this?  I am trying to determine how to print ranges.. for example, print the first 200 lines, then print lines 201-400, then print lines 401-600, etc.

Who is Participating?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
DECLARE @stmp varchar(max)
SET @stmp = ISNULL(@sSQL,'')
WHILE @stmp <> ''
   PRINT LEFT(@stmp, 1000)
   SET @stmp = substring(@stemp, 1001, len(@stemp))
jamesdean666Author Commented:
Thanks so much!

F.Y.I... For anyone subsequent viewers.. slight typo in solution.. @stemp = @stmp
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.