Sql-server – How to store long string with netstring format in varchar column

jsonsql servervarchar

I am involved in project where we have to store very long string in varchar column (varchar(max)). Due to this case have to questions:

  1. This column is one of other 40 columns in table (but only this has to be varchar(max)). To this table we will insert approximately 300 records per second. What is more this table will be partitioned for 32 partitions. What will be a good practise ?:
  • Leave this column in this table
  • Create new table with this column and ID (FK (references to main table)) ?
  • Any other approach ?
  1. Data in this column will be stored in netstring format. Moreover we will have to retrieve some specific field from this long string from this column. What is the best and most efficient way to do that ? Is it s good idea to for example to parse this netstring to json format ?

Thank you in advance for your answers 🙂

Best Answer

Don't worry about where you put the column. In the background the sql server will store it in a special place (allocation unit for lob_data). See here

So keep it simple and leave the column in the table.

Now if you have a possibility to store it as json instead of netstring try to do that as the sql server has native functionality to deal with json since version 2016