25 pts.
 using a local variable to build an sql-statement beyond datatype nvarchar(4000) and execute with sp_executesql
I build a sql-statement and put it in a local variable so i can execute it using sp_executesql, but a local variable cannot be a text or ntext data type, and a varchar data type cannot be used by sp_executesql. So the maximum lenght of the statement cannot be more than nvarchar(4000)... is there any work around?

Software/Hardware used:
ASKED: February 6, 2008  4:59 PM
UPDATED: February 6, 2008  5:32 PM

Answer Wiki:
Pretty much no. I ran into this same problem with some dynamic SQL that we had, and I had to remove some of the code from the dynamic SQL and pass it's results into the sp_executesql via the parameter. Do as much of the logic as you can outside of the dynamic SQL so that only the final select statement is dynamic.
Last Wiki Answer Submitted:  February 6, 2008  5:32 pm  by  Denny Cherry   64,520 pts.
All Answer Wiki Contributors:  Denny Cherry   64,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.

 64,520 pts.