SQL stored procedures

Source: Internet
Author: User
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,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.