Link to home
Start Free TrialLog in
Avatar of Omer-Pitou
Omer-Pitou

asked on

SQL Server 2008 R2: Execute a Dynamic SQL Statement of more than 10,000 characters

Hi,
I am busy completing a tracking table change stored procedure.  The code is running pretty good with small tables (tables with less fields).
I am facing a problem where the dynamic sql statement  size is more than 8000 characters.
I even tried to break it into small pieces like EXEC (@stmt1 + @stmt2 + @ stmt3 + @stmt4), but still can't beat it.
Any input is welcome.
Note: The sql  involves the use of UNPIVOT and related fields list comes from a variable, and is formated in a way where It allows conversion of all fields to VARCHAR.
SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Omer-Pitou
Omer-Pitou

ASKER

This works finally: EXEC (@stmt1 + @stmt2 + @stmt3 + @stmt4) .
I was missing something in the previous test.
Thanks for your time