Solved

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

Posted on 2014-03-21
3
544 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
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 300 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 28

Expert Comment

by:sammySeltzer
ID: 39945836
You are very welcome.

Glad things worked out for you.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now