Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which datatype can be used for storing HTML files in database?

I want to store a webpage in Sql Server. The page may contain images and other stuff. What data type should I use? As mentioned here, ntext, text, and image data types will be removed in the future versions of SQL Server. What data type can be used to store HTML files which have different stuff like images and things like JavaScript codes?

like image 297
Green Falcon Avatar asked Nov 11 '16 08:11

Green Falcon


2 Answers

Since you want to store both the HTML of the web page as well as the images, you might want to consider storing the images in the file system instead. Here is a comparison of the advantages and disadvantages of both options:

  • Storing Images in DB - Yea or Nay?

If you decide to store them in the DB, the appropriate data types are:

  • nvarchar(MAX) for the HTML text and
  • varbinary(MAX) for the images.
like image 166
Heinzi Avatar answered Sep 20 '22 12:09

Heinzi


I could store them in the DB, by

using nvarchar(MAX). it has stored the data as well as retrieved data with the image.

My objective was to copy and paste emails received. These emails can have HTML tags and can also have images. I tried it with nvarchar(max) and it worked.

I am using VB6 as a development tool. The only problem I found was I could not store it with stored procedures passing the values through addParameter.

I have stored it with traditional saving mechanism from VB6

With Recordset<br>
 .addnewM<br>
 .Fields("MailBody")<br>
 .Update<br>
End With<br>

If anyone gets idea of storing using the stored procedure, let me know

like image 37
Code4Business Avatar answered Sep 21 '22 12:09

Code4Business