The local variables in the stored procedure do not support text data! It hurts me. Because SQL is too long, and all data operations must be implemented in the stored procedure, there is no way, the text type does not support add and other operations.
The method I came up with is to use the text type as the input parameter, and then add several nvarchar data as the input parameter, for example:
Create procedure text_test
@ SQL text,
@ Test1 nvarchar (4000 ),
@ Test2 nvarchar (4000 ),
@ Test3 nvarchar (4000 ),
As
Begin
Set @ SQL = @ test1 + 'Union '+ @ Test2 + 'Union' + @ test3
End
Although the text type does not support add or other operations, the value-based operation is still supported.
Therefore, if a large SQL statement with a length greater than 4000 is to be passed to the stored procedure operation, it is better to split several segments. Different operations may vary depending on different requirements,