Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Cast Ntext to Varchar

Author  Topic 

cidmi.dovic
Yak Posting Veteran

53 Posts

Posted - 2008-06-13 : 19:16:55
I'm trying to cast a Ntext field to varchar and the output is

"The text, ntext, and image data types are invalid in this subquery or aggregate expression."

Declare @a as varchar(8000)

Set @a = Cast((Select ntextfield from db wher Pk=1) as varchar(8000))

I read in the help that it's possible a conversion between ntext and varchar. Am I wrong? Thanks in advance.

The Padrón peppers itch and other don't

cidmi.dovic
Yak Posting Veteran

53 Posts

Posted - 2008-06-13 : 19:30:03
Easy solution,

Set @a = (Select cast(varchar(8000),ntextfield) from db wher Pk=1)

The Padrón peppers itch and other don't
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-14 : 13:01:09
quote:
Originally posted by cidmi.dovic

Easy solution,

Set @a = (Select convert(varchar(8000),ntextfield) from db wher Pk=1)

The Padrón peppers itch and other don't



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -