troubleshooting Question

SQL 2005: The data types text and varchar are incompatible in the equal to operator

Avatar of Memorix
MemorixFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL Server
8 Comments1 Solution25481 ViewsLast Modified:
Hi,

I've wrote a search module for SQL Server 2000 a while back and it produces queries like:-

SELECT tblSection.SectionShortDesc as SectionShortDesc, tblPage.PageID, tblPage.PageName, tblPage.PageTitle
FROM (tblPage INNER JOIN tblPage2Section ON tblPage.PageID = tblPage2Section.PageID)
INNER JOIN tblSection ON tblPage2Section.SectionID = tblSection.SectionID
WHERE ((CHARINDEX('test', CONVERT(varchar(8000), tblSection.SectionShortDesc, 103)) > 0))
AND PageCat <> 'Products' AND PageCat <> 'Weight Watchers'
ORDER BY tblPage.PageTitle, tblPage.PageID, tblPage.PageName;

This query works fine on several sites running SQL Server 2000.  I am now needing to implement this same functionality on SQL 2005 but when i execute this query i get the following error message

#####################################

Microsoft OLE DB Provider for SQL Server error '80040e14'

The data types ntext and varchar are incompatible in the add operator.

/walkerssql/index.asp, line 1627

#####################################

I've tried changing CONVERT(varchar(8000), tblSection.SectionShortDesc, 103) to CONVERT(nvarchar(max), tblSection.SectionShortDesc, 103) as i've seen in several articles on google but it still give the same result.

Any suggestions on how to resolve this?
ASKER CERTIFIED SOLUTION
PashaMod

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros