views:

209

answers:

3

I know I can convert the variables to nvarchar(max) first and then compare with the = or <> operators. But is this the right way?

A: 

I've also found this

Nestor
+1  A: 

Yes, I think that's the best way to go - short of actually converting your NTEXT columns to NVARCHAR(MAX).

NVARCHAR(MAX) is much easier to work with than NTEXT, since it supports all the string functions that SQL Server has.

NTEXT will be phased out some time soon - try to switch to NVARCHAR(MAX) as soon as possible. You won't loose anything and only gain additional useful capabilities.

Marc

marc_s
A: 

You can also check out this Stack Overflow thread. The same technique can be used to separate an image value into 8000-byte chunks can be used to separate ntext into 4000-byte chunks. While it's not likely to come up, be aware that there may be some gotchas about ntext and SUBSTRING if you are unlucky enough to have any Unicode surrogate pairs in your ntext value.

Steve Kass