- Posted by justin on January 17, 2007
One of the questions that I had using ActiveRecord was how to deal with Text fields in a MS SQL Server Database. I ran across the post below.
From http://www.ayende.com/Blog/2006/12/30/NHibernateAndLargeTextFieldsGotchas.aspx
There are two gotchas associated with working with large text fields with NHibernate.
The first is that you must specify type="StringClob" (or ColumnType = "StringClob" in Active Record), if you are using SQL Server, since NHibernate needs to set the Size property on the parameters.
The second is that if you plan of letting NHibernate generate your schema, you need to specify sql-type="NTEXT" (or SqlType="NTEXT" in Active Record), otherwise NHibernate will generate an NVARCHAR field.
when using SQL-Server 2005 and it's dialect, you can spare the "StringClob" thingie. SQL-Server 2005 allows nvarchar(MAX), which gives you the length of ntext, the full-text indexing ability, and the nvarchar syntax (like, '%', concatenation, etc.)
The trick is the elimination of the "record cannot span pages". since now it can, you can use a "normal" field, with no length limit. (the actual length limit of about 4 zilion characters is not really a limit).