Solved

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

Posted on 2014-03-21
3
546 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

911 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

22 Experts available now in Live!

Get 1:1 Help Now