Text message template (Replace with the replace function in SQL)

Source: Internet
Author: User
Template:

[Ownername] [ownertitle], hello! I'm a [projectname] Insurance Company clerk [username], your [quotecontent]. If you are not clear, contact the service hotline: (PublicCompany [projectcontactphone]) or (personal [usermobilephone]). Thank you for checking it! Wish you good health!

Task: Set […] Content is replaced with the actual content

Code:

String SQL = "declare @ ownermobile varchar (250) \ r \ n ";
SQL + = "declare @ ownername varchar (250) \ r \ n ";
SQL + = "declare @ ownertitle varchar (250) \ r \ n ";
SQL + = "declare @ projectname varchar (100) \ r \ n ";
SQL + = "declare @ username varchar (100) \ r \ n ";
SQL + = "declare @ projectcontactphone varchar (100) \ r \ n ";
SQL + = "declare @ usermobilephone varchar (100) \ r \ n ";
SQL + = "declare @ quotecontent varchar (4000) \ r \ n ";
SQL + = "declare @ messagetemplate varchar (1000) \ r \ n ";

SQL + = "select @ ownermobile =. mobile, @ ownername =. ownername, @ ownertitle = case. sex when '1' Mr. 'when' 2 'then' Miss 'else' 'end, @ quotecontent = B. quotecontent, @ projectname = C. projectname, @ projectcontactphone = C. contactphone, @ username = D. username, @ usermobilephone = isnull (D. mobilephone, ''), @ messagetemplate = C. messagetemplate from [sales_carowners] A \ r \ n"
+ "Left join [sales_quotebill] B on A. [carid] = B. [carid] \ r \ n"
+ "Left join [sales_system_project] C on B. projectid = C. ID \ r \ n"
+ "Left join [system_users] D on B. quoteuserid = D. userid \ r \ n"
+ "Where B. [ID] =" + quoteid + "\ r \ n ";

// Replace
SQL + = "set @ messagetemplate = Replace (@ messagetemplate, '[ownername]', @ ownername) \ r \ n ";
SQL + = "set @ messagetemplate = Replace (@ messagetemplate, '[ownertitle]', @ ownertitle) \ r \ n ";
SQL + = "set @ messagetemplate = Replace (@ messagetemplate, '[projectname]', @ projectname) \ r \ n ";
SQL + = "set @ messagetemplate = Replace (@ messagetemplate, '[username]', @ username) \ r \ n ";
SQL + = "set @ messagetemplate = Replace (@ messagetemplate, '[quotecontent]', @ quotecontent) \ r \ n ";
SQL + = "set @ messagetemplate = Replace (@ messagetemplate, '[projectcontactphone]', @ projectcontactphone) \ r \ n ";
SQL + = "set @ messagetemplate = Replace (@ messagetemplate, '[usermobilephone]', @ usermobilephone) \ r \ n ";

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.