How insrt bulk html code into table using insert query

Posted by santoshkumar413-24453 under Sql Server on 5/14/2014 | Points: 10 | Views : 1417 | Status : [Member] | Replies : 3
Hi,

I am trying to insert into following html code into a column using sql query but "incorrect syntax error near Arial" message is coming. This error is coming because of mismatch of opening single code and closing single code.

Please help me to insert bulk of html code like below into table using sql server

I need a query which can insert bulk html code into table irrespective of no. of code, no. of braces....etc....


"
<p><strong><span style="background: yellow;">A.</span></strong><strong><span style="background: yellow; font-family: 'Arial','sans-serif';"> </span><span style="background: yellow;">Air Conditioning System of Accommodation Decks &amp; SCR Room </span></strong></p>
"

insert into Quatations value('
<p><strong><span style="background: yellow;">A.</span></strong><strong><span style="background: yellow; font-family: 'Arial','sans-serif';"> </span><span style="background: yellow;">Air Conditioning System of Accommodation Decks &amp; SCR Room </span></strong></p>
')




Thanks,
Santosh




Responses

Posted by: Adsingh_Naz on: 5/14/2014 [Member] Starter | Points: 25

Up
0
Down
You can make the single quotes in Arial to double single quotes to get rid of this error

DECLARE @HTML TABLE(Code VARCHAR(1000))

INSERT INTO @HTML(Code)
VALUES('
<p><strong><span style="background: yellow;">A.</span></strong><strong><span style="background: yellow; font-family: ''Arial'',''sans-serif'';"> </span><span style="background: yellow;">Air Conditioning System of Accommodation Decks &amp; SCR Room </span></strong></p>
');

SELECT code FROM @HTML


santoshkumar413-24453, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 5/22/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Just use two single quotes to have single quote in the column data...

insert into Quatations value('
<p><strong><span style="background: yellow;">A.</span></strong><strong><span style="background: yellow; font-family: ''Arial'',''sans-serif'' ;"> </span><span style="background: yellow;">Air Conditioning System of Accommodation Decks &amp; SCR Room </span></strong></p>
')


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

santoshkumar413-24453, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: santoshkumar413-24453 on: 5/23/2014 [Member] Starter | Points: 25

Up
0
Down
Hi thanks for your reply Ihave solved that issue by creating stored procedure passing the content holder of that html code as parameter.

santoshkumar413-24453, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response