[dba-SQLServer] Convert from ntext to varchar

Mike & Doris Manning mikedorism at adelphia.net
Thu Jan 6 13:26:35 CST 2005


The answer to your bulk up question is "NO".  If you were using CHAR
datatype it would because SQL would pad the field with enough spaces to make
8000 characters.  With VARCHAR, that does not happen.

Doris Manning
Database Administrator
Hargrove Inc.
www.hargroveinc.com


-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Steven W.
Erbach
Sent: Thursday, January 06, 2005 1:53 PM
To: dba-sqlserver at databaseadvisors.com
Subject: RE: [dba-SQLServer] Convert from ntext to varchar


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


_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com






More information about the dba-SQLServer mailing list