Maxwell175
Maxwell175

Reputation: 1933

How to store large, multi-line text in SQL Server?

What would be the best way to store a large amount of text in a Database? I would expect about 2500 words and since on average each word in English is around 6 characters, I expect over 15000 characters. This text may be non-English so I guess I would need Unicode to support everything.

This text needs to be inserted, retrieved, and also searched by keywords.

Maxwell.

Upvotes: 1

Views: 10509

Answers (3)

Sateesh Pagolu
Sateesh Pagolu

Reputation: 9606

You need to use NVARCHAR(MAX)

You can store..

1 billion, 73 million, 741 thousand and 823 characters

Upvotes: 3

Jonathan Solorzano
Jonathan Solorzano

Reputation: 7032

If you will insert non-english characters you have to use NVARCHAR, and also when inserting the data you have to prefix it with an N like this:

CREATE TABLE tmp( description NVARCHAR(MAX) )
INSERT INTO tmp VALUES (N'Добро...')

Upvotes: 2

Rahul
Rahul

Reputation: 77926

You should use NVARCHAR(MAX) as the datatype for that particular column in question. Also, I would suggest you have a FULLTEXT INDEX on that column since you said that column will also include searching by keywords.

Upvotes: 4

Related Questions