Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to store a large amount of text in a SQL server table?

Tags:

sql-server

What is the best way to store a large amount of text in a table in SQL server?

Is varchar(max) reliable?

like image 959
Bruno Avatar asked Sep 26 '08 16:09

Bruno


People also ask

How do I store large amounts of text in SQL?

If you want to store large amounts of text in a SQL database, then you want to use either a varchar(max) or a nvarchar(max) column to store that data. In case you don't know the difference, nvarchar will support Unicode characters.

What is best way to store an attribute of large string values in SQL?

The MEDIUMTEXT data object is useful for storing larger text strings like white papers, books, and code backup. These data objects can be as large as 16 MB (expressed as 2^24 -1) or 16,777,215 characters and require 3 bytes of overhead storage.

How do you handle a large amount of data in SQL?

The most recommended and best option is to have a STANDBY server, restore the backup of the production database on that server, and then run the DBCC command. If the consistency checks run ok on the standby database, the production database should be ok as it is the source of the standby.

How can we store long string in SQL Server?

n defines the string length and can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). DECLARE @longText varchar(max); SET @longText = REPLICATE('X', 8000); SET @longText = @longText + REPLICATE('X', 8000); SELECT DATALENGTH(@longText); Returns 16 K of characters.


1 Answers

In SQL 2005 and higher, VARCHAR(MAX) is indeed the preferred method. The TEXT type is still available, but primarily for backward compatibility with SQL 2000 and lower.

like image 83
John Rudy Avatar answered Sep 25 '22 02:09

John Rudy