Insert an html into a table using sql server

Asked

Viewed 663 times

-1

How could an Insert in a table of an HTML code?

Example:

insert into TB_CONTEUDO (CONT_TITULO, CONT_HTML, CONT_COCA_FK_ID, CONT_META_TAG)
values('Teste','',17,'')

CONT_HTML = html one-page

2 answers

0

Try the following

Put everything into a variable, and assuming you have it is variable:

var html = "<html><body>Html aqui</body></html>"

And in Insert do the following:

insert into TB_CONTEUDO (CONT_TITULO, CONT_HTML, CONT_COCA_FK_ID, CONT_META_TAG)
values('Teste',?,17,''), [html]

I’m not sure it will work because I’m far from my laptop, but try to tell me later, if it doesn’t work I edit the answer :)

-1

The same way you wrote here, you’re gonna save this field like you’re saving one String usually the only concern you should have is to check your HTML content does not exceed the character limit of your field.

A great type to save your HTML content to SQL Server, would be the NVARCHAR(MAX)

insert into TB_CONTEUDO (CONT_TITULO, CONT_HTML, CONT_COCA_FK_ID, CONT_META_TAG)
values('Teste','<html><body>seu conteúdo html</body></html>',17,'')
  • in a small html I also know, why it is great

  • @itasouza HTML is nothing more than a text and in this case it should be inserted as if it were a text. If your html is large it is good to use your field as Nvarchar(Max), for it to fit normally. If Nvarchar n serves you, you can use a text field for example.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.