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 2008 Forums
 Transact-SQL (2008)
 CAST ntext AS nvarchar(max)

Author  Topic 

e.roc
Starting Member

5 Posts

Posted - 2010-05-18 : 14:22:55
Supposedly this is possible, but I am getting Data type mismatch - no conversion possible. Ultimately I am trying to create a UNION of two queries that include one ntext field, but I understand UNION is not possible with ntext because you cannot SELECT DISTINCT, so I am trying to CAST or CONVERT but neither works. Any ideas? Thanks.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-05-18 : 16:00:24
I'm not sure exactly what the issue is. Can you give more detail?

You can cast a ntext as nvharcar(max) easily enough. True you can't use UNION, but you can use UNION ALL. But, maybe that will not work for your scenario though.

Maybe this will help:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

e.roc
Starting Member

5 Posts

Posted - 2010-05-18 : 17:21:54
Sorry - I am a newbee here. I will work on better question format.

UNION ALL did the trick - good call. I never realized that UNION implied grouping over the whole result set.

I had been getting an error trying to CAST/CONVERT from ntext to nvarchar when building my query using the grid in SQL Management Studio, but I did not get the error when I type it in the SQL statement window. However, using UNION ALL, I do not neet to CAST/CONVERT.

Thanks again!
Go to Top of Page
   

- Advertisement -