?
Solved

SQL 2005 Error Msg 306, Level 16, State 2, Line 1

Posted on 2014-03-21
3
Medium Priority
?
570 Views
Last Modified: 2014-03-21
I'm trying to run the below query and getting an error...  The comments field from the Payments table is an 'ntext' field.  

The error:
Msg 306, Level 16, State 2, Line 1
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.


Anybody know a work around?


SELECT       p.payment_dt
      , p.amount
      , p.check_no
      , p.inv_no
      , p.comments
      , i.inv_date
FROM Payments as p, invoices as i
WHERE  i.acct='1725bal' and p.inv_no=i.inv_no and p.payment_dt >= '01/01/2013' and p.payment_dt <= '1/31/2014'
GROUP BY p.payment_dt, p.amount, p.check_no, p.inv_no, p.comments, i.inv_date
ORDER BY p.payment_dt
0
Comment
Question by:RavenTim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
sammySeltzer earned 1200 total points
ID: 39945376
Change ntext to nvarchar(MAX).

You can perform the function you are trying to run with nvarchar(max) but not with ntext and if I am not mistaken, ntext, along with text are being phased out.

See more here:
http://msdn.microsoft.com/en-us/library/ms187993.aspx
0
 

Author Closing Comment

by:RavenTim
ID: 39945805
Thanks Sammy!  It did the trick!!
0
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 39945836
You are very welcome.

Glad things worked out for you.
0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question