Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 585
  • Last Modified:

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

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
RavenTim
Asked:
RavenTim
  • 2
1 Solution
 
sammySeltzerCommented:
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
 
RavenTimAuthor Commented:
Thanks Sammy!  It did the trick!!
0
 
sammySeltzerCommented:
You are very welcome.

Glad things worked out for you.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now