Oviic
Oviic

Reputation: 45

Store a big String in database?

What is the best way to store a a big String in SQL server Database.

I'm using varchar(8000) but I get this exception while persisting my Object using Hibernate :

>Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.

Upvotes: 2

Views: 2592

Answers (3)

Gatusko
Gatusko

Reputation: 2608

Well as I can see the tag of hibernate you need the tag of @Lob for storing super large objects.

Specifies that a persistent property or field should be persisted as a large object to a database-supported large objec

Example:

@Lob @Basic(fetch=LAZY)
   @Column(name="REPORT")
   protected String report;

From Hibernate Docs.

Upvotes: 1

Gopakumar N.Kurup
Gopakumar N.Kurup

Reputation: 936

Which version of SQL Server are you using? If the version is above 2005 Use VARCHAR(MAX). If the version is before 2005 you can use TEXT

Upvotes: 3

apomene
apomene

Reputation: 14389

When you want to store a very big string on SQL Server you can use:

 varchar(max) 

Upvotes: 1

Related Questions