Search code examples
sql-serversql-server-2008large-text

suitable data type to save string larger than 8000 charachter


what is the suitable data type to save string more than 8000 character in SQL database?


Solution

  • For SQL Server 2005+ varchar(max) or nvarchar(max) depending on whether you need to save as unicode or not.

    If you don't have this requirement (or anticipate ever needing it) the varchar option is more space efficient.

    You don't give a specific version of SQL Server in your question. Pre 2005 it would have been the text datatype.

    NB: In answer to your comment use 'varchar(max)' exactly as written. Don't substitute a number in for "max"!