[dba-SQLServer] Convert from ntext to varchar

Steven W. Erbach serbach at new.rr.com
Thu Jan 6 12:52:56 CST 2005


Chris,

I was able to modify the SQL statement using your CAST suggestion. However when I executed the sproc, the NewKeyStatsComment field only had 16 characters of data in it.

My understanding of the varchar data type is that it's variable in length, like the ntext type. My table definition has ntext(16) for the current KeyStatsComment column. Of course, the comments are longer than 16 characters and they show up just fine in the table. But I've defined the NewKeyStatsComment column as varchar(16).

I suppose if I modified the NewKeyStatsComment to varchar(8000) then the entire comment would fit in the field. But doesn't SQL Server then bulk up the table by the 8000 characters per row? Or what?

Steve Erbach
Neenah, WI

> ------------Original Message------------
> From: "Mackin, Christopher" <CMackin at quiznos.com>
> To: dba-sqlserver at databaseadvisors.com
> Date: Thu, Jan-6-2005 9:00 AM
> Subject: RE: [dba-SQLServer] Convert from ntext to varchar
> 
> Try:
> CAST(KeyStatsComment AS varchar(16))
> 
> Not specifying a length for the VarChar field may be causing the 
> problem.
> 
> -Chris Mackin





More information about the dba-SQLServer mailing list