locked
Good idea to save large amounts of text in db? RRS feed

  • Question

  • User1655654435 posted

    Hi, I have an asp.net core app that needs to save large amounts of texts to be used throughout the application.

    These sections of text probably needs to be formatted with html because i need to paste them into a webpage.

    So how much text can I store within a string property? It would look something like this : string Article = "<h1>Title</h1><p>Bulk of text...</p>"

    The other alternative would be just to hardcode the text withing the html page, but then I would need to create 16 pages instead of 1.

    Any thoughts?

    Wednesday, June 27, 2018 7:47 AM

Answers

  • User1724605321 posted

    Hi bluMarmalade ,

    You can use VARCHAR(MAX) or NVARCHAR(MAX) can hold the same amount of data that the old TEXT and NTEXT could hold , approximately 2GB of data. 

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 28, 2018 3:12 AM
  • User-821857111 posted

    The other alternative would be just to hardcode the text withing the html page, but then I would need to create 16 pages instead of 1.
    That's exactly the problem that combining a database with a dynamic web development framework are intended to solve. 

    Others have already addressed the "limitations" of using an nvarchar(max) column. The maximum amount of data that you can store in a .NET string is also 2GB (theoretically).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 4, 2018 9:40 AM

All replies

  • User1724605321 posted

    Hi bluMarmalade ,

    You can use VARCHAR(MAX) or NVARCHAR(MAX) can hold the same amount of data that the old TEXT and NTEXT could hold , approximately 2GB of data. 

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 28, 2018 3:12 AM
  • User-821857111 posted

    The other alternative would be just to hardcode the text withing the html page, but then I would need to create 16 pages instead of 1.
    That's exactly the problem that combining a database with a dynamic web development framework are intended to solve. 

    Others have already addressed the "limitations" of using an nvarchar(max) column. The maximum amount of data that you can store in a .NET string is also 2GB (theoretically).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 4, 2018 9:40 AM
  • User-1171043462 posted

    You can save Long strings in database easily.

    Check this article: Simple Blog Tutorial with example in ASP.Net using C# and VB.Net

    Here I am saving the Text from HTML editor in database and also displaying it. Similar to what you need

    Wednesday, July 4, 2018 10:05 AM