[dba-SQLServer] Convert from ntext to varchar

Mackin, Christopher CMackin at quiznos.com
Thu Jan 6 08:59:53 CST 2005


Try:
CAST(KeyStatsComment AS varchar(16))

Not specifying a length for the VarChar field may be causing the problem.

-Chris Mackin

-----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 3:39 AM
To: dba-sqlserver at databaseadvisors.com
Subject: [dba-SQLServer] Convert from ntext to varchar


Dear Group,

It seems that it might be a good idea to convert the ntext Comment columns I have in a number of tables to varchar, even though the maximum length is much less and there's no Unicode capability. The Comments in these tables aren't going to be book length.

I'm having trouble, though converting from ntext to varchar. The existing columns are all ntext 16. I've tried using a stored procedure like this:

CREATE PROCEDURE _spTmpConvertKeyStatsComment AS
UPDATE tblKeyStats
SET NewKeyStatsComment = CAST(KeyStatsComment AS varchar)

GO

In the tblKeyStats table I added a varchar 16 column named NewKeyStatsComments. As you can see I tried to use the CAST function. When I run this sproc in a SQL script, none of the data is copied into the NewKeyStatsComment column. I will say that some of the original KeyStatsComment values are NULL.

Any thoughts?
 
Regards,
 
Steve Erbach
Scientific Marketing
Neenah, WI




_______________________________________________
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