2

Hi,

I try to put some html and csss as a record in MSSQL Database. I have this:

IF NOT EXISTS (SELECT * FROM Beheer.EmailTemplateType WHERE Omschrijving = 'Wachtwoord vergeten')
BEGIN
    INSERT INTO Beheer.EmailTemplateType (Omschrijving, Html)
    VALUES
    (
        'Wachtwoord vergeten',      
        '<html> <head>  <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700" rel="stylesheet"><style type="text/css"> .td {font-family:"Open Sans", Arial, 'Helvetica Neue', Helvetica,  sans-serif;  color:#666666;  font-size:13px;     font-weight: normal;    line-height:150%;   letter-spacing: normal;     text-align:left;    } </style>   </head>  <body style="background-color: #ffffff; margin: 0; padding: 0;">    <!-- Snippet tekst. editable -->      <!--[if !gte mso 9]><!----><span style="display:none; font-size:0px; line-height:0px; max-height:0px; max-width:0px; opacity:0; overflow:hidden; visibility:hidden; mso-hide:all;">Nog één stap te gaan... </span><!--<![endif]-->        <table border="0" cellpadding="0" cellspacing="0" width="100%">  <tr>     <td align="center">      <!-- Logo. editable - extra cel tbv positionering in gmail app -->                     <table width="480" border="0" cellpadding="0" cellspacing="0" style="max-width: 480px;">        <tr>            <td align="left" width="270">           <div align="left" style="float: left; text-align: left;">           <img src="http://www.sdbayton.nl/wp-content/uploads/2016/12/mainlogo_274x122.png" align="left" border="0" style="float:left;">          </div>          </td>           <td align="left" width="210">&nbsp;</td>        </tr>       </table>                                            </td>  </tr>   <tr>     <td align="center" style="padding-top: 20px">        <!-- Koptekst en introtekst. editable -->                  <table width="480" border="0" cellpadding="0" cellspacing="0" style="max-width: 480px;">            <tr>                <td align="left">                       <h1 style="font-family: 'Open Sans', Arial, Helvetica, sans-serif; font-size: 16px; color:#666666; font-weight: normal; line-height: 100%; letter-spacing: normal; text-align: left;">Stel je wachtwoord opnieuw in </h1>                                       <p style="font-family: 'Open Sans', Arial, Helvetica, sans-serif; font-size: 13px; color:#666666; font-weight: normal; line-height: 150%; letter-spacing: normal; text-align: left;"> Beste {Voornaam},<br> <br> Er is via dit e-mailadres een aanvraag voor een nieuw wachtwoord gedaan. <br> <br> Klik op onderstaande button om deze aanvraag af te ronden. </p>                         </td>           </tr>       </table>                    </td>  </tr>  <tr>      <td align="center">         <table width="480" border="0" cellpadding="0" cellspacing="0" style="max-width: 480px;">            <tr>                <td align="left">                <!-- Button met call 2 action, niet editable - let op!!: 2 maal een href -->                                           <table width="100%" border="0" cellpadding="0" cellspacing="0" align="left">                <tr>                    <td bgcolor="#ffffff " align="left" style="padding: 20px 0px 20px 0px;">                        <div><!--[if mso]>                        <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://testlink" style="height:40px;v-text-anchor:middle;width:200px;" arcsize="8%" stroke="f" fillcolor="#00b3e2 ">                           <w:anchorlock/>                             <center>                          <![endif]-->                            <a href="http://testlink"                         style="background-color:#00b3e2 ;border-radius:3px;color:#ffffff ;display:inline-block;font-family:sans-serif;font-size:13px;line-height:40px;text-align:center;text-decoration:none;width:200px;-webkit-text-size-adjust:none;">Wijzig je wachtwoord</a>                         <!--[if mso]>                             </center>                         </v:roundrect>                        <![endif]-->                           </div>                   </td>               </tr>           </table>      <!-- Optioneel tekstblok onder button, niet editable -->                  <table width="100%" border="0" cellpadding="0" cellspacing="0"  align="left">                   <tr>                        <td bgcolor="#ffffff " align="left">                            <p style="font-family: 'Open Sans', Arial, Helvetica, sans-serif; font-size: 13px; color:#666666; font-weight: normal; line-height: 150%; letter-spacing: normal; text-align: left;"> Deze link is eenmalig te gebruiken en 24 uur actief. Via de link <em>Wachtwoord vergeten</em> op het inlogscherm van {SDB Applicatienaam} is het altijd mogelijk een nieuw wachtwoord aan te vragen.<br> Doet de button het niet? Kopieer dan deze link naar je browser: {INLOGLINK} </p>                         </td>                   </tr>               </table>                                        </td>           </tr>           </table>                    </td>  </tr>    <tr>    <td align="center">       <!-- Tekstblok 2: afsluitend tekstje. editable -->                        <table width="480" border="0" cellpadding="0" cellspacing="0" style="max-width: 480px; padding-top:20px;">              <tr>                <td align="left">               <p style="font-family: 'Open Sans', Arial, Helvetica, sans-serif; font-size: 13px; color:#666666; font-weight: normal; line-height: 150%; letter-spacing: normal; text-align: left;"> Komt de aanvraag voor een nieuw wachtwoord niet bij jou vandaan? Dan mag je dit e-mailbericht negeren. <br> <br> <br> Met vriendelijke groet,<br> Het SDB Ayton Team                  </p>                                </td>           </tr>       </table>            </td>  </tr>                                <!-- td - padding-top voor witruimte  -->                                              <tr>     <td align="center" style="padding-top: 30px">        <!-- table 100% breed grijze backgroundkleur -->           <table cellpadding="0" cellspacing="0" width="100%">    <tr>        <td bgcolor="#f4f4f4" style="padding: 15px 0px 15px 0px;" align="center">                <!-- Footer. niet editable -->                                     <table width="480" border="0" cellpadding="0" cellspacing="0" style="max-width: 480px;">            <tr>                <td align="left">                                   <p align="left" style="font-family: 'Open Sans', Arial, Helvetica, sans-serif; font-size: 11px; color:#666666; font-weight: normal; line-height: 140%; letter-spacing: normal; text-align: left;"> Je ontvangt deze mail omdat je gebruik maakt van {SDB*Applicatienaam} via {TESTnaamwerkgever}. <br /> Dit is een automatisch bericht waar je niet op kunt antwoorden.<br> {SDB*Applicatienaam} is een dienst van SDB Ayton.                  </p>                                        </td>           </tr>           </table>                    </td>   </tr>   </table>        </td>  </tr>                   </table>      </body> </html> '



    )
END
GO

But I get an error on this line:

{font-family:"Open Sans", Arial, 'Helvetica Neue'

Incorrect syntax near '', Arial, Helvetica, sans-serif; font-size: 16px; color:#666666; font-weight: normal; line-height: 100%; letter-spacing: normal; text-align: left;">

is it because I have to put:

'Helvetica Neue' in double brackets?

like this:

"Helvetica Neue" ?

Thank you

1 Answer 1

2

You are getting this error because of the single quotes in your input string. In SQL if you want to insert a single quotes value, then you have to specify it as 2 single quotes. Like this

I want to insert the string I'm a Programmer to my table.

I'll get an error if I use the below

INSERT INTO MyTable(Msg)
VALUES('I'm a Programmer')

So instead, I've to write it like this

INSERT INTO MyTable(Msg)
VALUES('I''m a Programmer')

So, in your application, before you pass the input string (CSS ,HTML or anything) just replace all single quotes (') with 2 single quotes('')

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.