Today, a wonderful problem is encountered: The SQL string stitching in the stored procedure is too long, beyond the length of the nvarchar (4000) that the paging stored procedure executes the SQL parameter.
No way, you can only modify your own stored procedures, because the paging stored procedure is not moving.
The first way to think of it is to extract the inner SELECT statement, execute it with exec (Strinnersql), put the query data into a temporary table, use temporary tables in @s to get the data, and end up in the Times.
Error reason: The temporary table generated by EXEC (Strinnersql) was not found when executing the @s statement
Good depressed ah, how can this, clearly in a stored procedure execution, how temporary table can not get it??????????
It's going to be a long day.
Helpless, only the exec (strinnersql) execution of the SQL extracted, executed in code, let him produce a temporary table, and then in the stored procedure call
Surprised, incredibly successful.!!!!!!!!
God, can you tell me why?????????????????????????????
The first method why not, the second method is OK
Which big God is passing, must tell me to ask what!!!!!!!!!!!!!!
Resolves an issue where SQL statements are truncated due to lengthy SQL string concatenation in stored procedures