我正在尝试更新SQL Server中的HTML列,但遇到以下错误,但似乎无法解决。错误:
消息102,级别15,状态1,第1行附近的语法不正确 “投石机”。
我尝试在HTML上使用单引号和双引号,但是没有一个奏效。
update SC_EmailTemplates set HTML = '<p> </p> <center> <table style="text-align: left;" width="600" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="border-bottom: 1px solid #e4e4e4;" width="31" height="18"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td width="131" height="18"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td style="border-bottom: 1px solid #e4e4e4;" width="466" height="18"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> </tr> <tr> <td style="border-bottom: 1px solid #e4e4e4;" width="31" height="2"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td width="131" height="2"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td style="border-bottom: 1px solid #e4e4e4;" width="466" height="2"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> </tr> <!--GREEN STRIPE--> <tr> <td style="border-top: 1px solid #FFF; border-bottom: 1px solid #FFF;" bgcolor="#673090" width="31" height="113"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <!--WHITE TEXT AREA--> <td style="border-top: 1px solid #FFF; text-align: center;" valign="middle" bgcolor="#FFFFFF" width="131" height="113"><span style="font-size: 25px; font-family: Trebuchet MS, Verdana, Arial; color: #673090;">Hello!</span></td> <!--GREEN TEXT AREA--> <td style="border-top: 1px solid #FFF; border-bottom: 1px solid #FFF; padding-left: 15px;" bgcolor="#673090" height="113"><span style="color: #ffffff; font-size: 18px; font-family: Trebuchet MS, Verdana, Arial;">A quick email from Abcd. </span></td> </tr> <!--DOUBLE BORDERS BOTTOM--> <tr> <td style="border-top: 1px solid #e4e4e4; border-bottom: 1px solid #e4e4e4;" width="31" height="3"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td width="131" height="3"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td style="border-top: 0px solid #e4e4e4; border-bottom: 0px solid #e4e4e4;" height="3"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> </tr> <tr> <td colspan="3"><!--CONTENT STARTS HERE--> <br /> <br /> <table width="598" cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="15"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td style="padding-right: 10px; font-family: Trebuchet MS, Verdana, Arial; font-size: 12px;" valign="top" width="598"><span style="font-family: Trebuchet MS, Verdana, Arial; font-size: 17px; font-weight: bold;">Dear [Cr_Clients.NameFirst]</span> <br /> <p>[Message]</p> </td> </tr> </tbody> </table> <br /> <table style="border-top: 0px solid #e4e4e4; text-align: center; font-family: 'Trebuchet MS', Verdana, Arial; font-size: 12px; width: 586px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="border-bottom: 0px solid #e4e4e4; width: 589px;" colspan="3" height="2"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> </tr> <tr> <td style="font-family: 'Trebuchet MS', Verdana, Arial; font-size: 12px; width: 589px;" colspan="3"><a href="mailto:admin@abcd.org.uk?Subject=Unsubscribe Client Reference=[CR_Clients.Client_Ref]">Unsubscribe</a></td> </tr> <tr> <td style="font-family: 'Trebuchet MS', Verdana, Arial; font-size: 12px; width: 589px;" colspan="3"> <p>company address 123456798 asdf</p> </td> </tr> <tr> <td style="font-family: 'Trebuchet MS', Verdana, Arial; font-size: 12px; width: 123.5px;"> <p><a href="https://twitter.com/@abcde1"><img src="https://img.icons8.com/color/48/000000/twitter.png" alt="Follow us on Twitter" width="60" height="48" /></a></p> <p> <a href="https://twitter.com/@abcd1">Follow us on Twitter</a></p> </td> <td style="font-family: 'Trebuchet MS', Verdana, Arial; font-size: 12px; width: 347.5px;"> <p><a href="http://www.abcde.org.uk"><img src="http://abcd.org.uk/assets/images/logo.jpg" alt="Workabout" width="190" height="58" longdesc="http://www.workabout.org.uk" /></a></p> <p> </p> </td> <td style="font-family: 'Trebuchet MS', Verdana, Arial; font-size: 12px; width: 118px;"> <p><a href="https://www.facebook.com/abcd"><img src="https://img.icons8.com/color/48/000000/facebook.png" alt="Find us on Facebook" width="60" height="62" /></a></p> <p><a href="https://twitter.com/@abcde1">Find us on Facebook</a></p> </td> </tr> <tr> <td style="font-family: 'Trebuchet MS', Verdana, Arial; font-size: 12px; background: #673090; width: 589px;" colspan="3"> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center>'
where ID =57;
答案 0 :(得分:1)
使用单引号时,必须将文字字符串中的双引号加倍(转义)。因此,对于“ do n't”之类的值,您将使用'don''t'
。
UPDATE SC_EmailTemplates
SET HTML = '<p> </p> <center> <TABLE style="text-align: left;" width="600" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="border-bottom: 1px solid #e4e4e4;" width="31" height="18"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td width="131" height="18"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td style="border-bottom: 1px solid #e4e4e4;" width="466" height="18"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> </tr> <tr> <td style="border-bottom: 1px solid #e4e4e4;" width="31" height="2"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td width="131" height="2"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td style="border-bottom: 1px solid #e4e4e4;" width="466" height="2"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> </tr> <!--GREEN STRIPE--> <tr> <td style="border-top: 1px solid #FFF; border-bottom: 1px solid #FFF;" bgcolor="#673090" width="31" height="113"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <!--WHITE TEXT AREA--> <td style="border-top: 1px solid #FFF; text-align: center;" valign="middle" bgcolor="#FFFFFF" width="131" height="113"><span style="font-size: 25px; font-family: Trebuchet MS, Verdana, Arial; color: #673090;">Hello!</span></td> <!--GREEN TEXT AREA--> <td style="border-top: 1px solid #FFF; border-bottom: 1px solid #FFF; padding-left: 15px;" bgcolor="#673090" height="113"><span style="color: #ffffff; font-size: 18px; font-family: Trebuchet MS, Verdana, Arial;">A quick email from Abcd. </span></td> </tr> <!--DOUBLE BORDERS BOTTOM--> <tr> <td style="border-top: 1px solid #e4e4e4; border-bottom: 1px solid #e4e4e4;" width="31" height="3"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td width="131" height="3"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td style="border-top: 0px solid #e4e4e4; border-bottom: 0px solid #e4e4e4;" height="3"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> </tr> <tr> <td colspan="3"><!--CONTENT STARTS HERE--> <br /> <br /> <table width="598" cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="15"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> <td style="padding-right: 10px; font-family: Trebuchet MS, Verdana, Arial; font-size: 12px;" valign="top" width="598"><span style="font-family: Trebuchet MS, Verdana, Arial; font-size: 17px; font-weight: bold;">Dear [Cr_Clients.NameFirst]</span> <br /> <p>[Message]</p> </td> </tr> </tbody> </table> <br /> <table style="border-top: 0px solid #e4e4e4; text-align: center; font-family: ''Trebuchet MS'', Verdana, Arial; font-size: 12px; width: 586px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="border-bottom: 0px solid #e4e4e4; width: 589px;" colspan="3" height="2"> <div style="line-height: 0px; font-size: 1px; position: absolute;"> </div> </td> </tr> <tr> <td style="font-family: ''Trebuchet MS'', Verdana, Arial; font-size: 12px; width: 589px;" colspan="3"><a href="mailto:admin@abcd.org.uk?Subject=Unsubscribe Client Reference=[CR_Clients.Client_Ref]">Unsubscribe</a></td> </tr> <tr> <td style="font-family: ''Trebuchet MS'', Verdana, Arial; font-size: 12px; width: 589px;" colspan="3"> <p>company address 123456798 asdf</p> </td> </tr> <tr> <td style="font-family: ''Trebuchet MS'', Verdana, Arial; font-size: 12px; width: 123.5px;"> <p><a href="https://twitter.com/@abcde1"><img src="https://img.icons8.com/color/48/000000/twitter.png" alt="Follow us on Twitter" width="60" height="48" /></a></p> <p> <a href="https://twitter.com/@abcd1">Follow us on Twitter</a></p> </td> <td style="font-family: ''Trebuchet MS'', Verdana, Arial; font-size: 12px; width: 347.5px;"> <p><a href="http://www.abcde.org.uk"><img src="http://abcd.org.uk/assets/images/logo.jpg" alt="Workabout" width="190" height="58" longdesc="http://www.workabout.org.uk" /></a></p> <p> </p> </td> <td style="font-family: ''Trebuchet MS'', Verdana, Arial; font-size: 12px; width: 118px;"> <p><a href="https://www.facebook.com/abcd"><img src="https://img.icons8.com/color/48/000000/facebook.png" alt="Find us on Facebook" width="60" height="62" /></a></p> <p><a href="https://twitter.com/@abcde1">Find us on Facebook</a></p> </td> </tr> <tr> <td style="font-family: ''Trebuchet MS'', Verdana, Arial; font-size: 12px; background: #673090; width: 589px;" colspan="3"> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center>'
WHERE ID = 57;
尽管如此之所以难以解决,是因为您的HTML中没有一个换行符。良好地使用空白和换行符对于每种语言都至关重要。就像语法在口头语言中至关重要。没有它,您所拥有的只是一团糟。