Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CAST or CONVERT from ntext to varchar? how?

Status
Not open for further replies.

MrPeds

Programmer
Jan 7, 2003
219
GB
Hi,

i) Is it possible to convert a database field that is an ntext data type to a simple nvarchar data type in a SELECT query? If so, how?

e.g. is it like SELECT col1, col2, CAST(col3, nvarchar(10) ), FROM tbl

ii) Furthermore, is it possible to do a CONVERT (or CAST) from an ntext data type to nvarchar in a subquery as i got errors relating to this when I tried combining the principles. e.g.

SELECT col1, col2, (sub query 1), (SELECT CAST(ntextfield, nvarchar) FROM tbl...), ... ?

Thanks in advance,

MrPeds
 
yes you can cast and conver ntext to nchar or nvarchar, but it will get truncated becasue you cannot store the same number of characters in both datatypes.

You didn;t specify the length of nvarchar in your 2nd example. Perhaps maybe that was the problem?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top