• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1543
  • Last Modified:

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:

PRINT @sSQL

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.

Thanks!
0
jamesdean666
Asked:
jamesdean666
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
DECLARE @stmp varchar(max)
SET @stmp = ISNULL(@sSQL,'')
WHILE @stmp <> ''
BEGIN
   PRINT LEFT(@stmp, 1000)
   SET @stmp = substring(@stemp, 1001, len(@stemp))
END
0
 
jamesdean666Author Commented:
Thanks so much!

F.Y.I... For anyone subsequent viewers.. slight typo in solution.. @stemp = @stmp
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now