[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2014-03-21
3
Medium Priority
?
578 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

656 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