troubleshooting Question

Error: "A severe error occurred on the current command" when attempting query which uses any form of sorting

Avatar of Dale Fye
Dale FyeFlag for United States of America asked on
Microsoft SQL Server
4 Comments1 Solution59 ViewsLast Modified:
I'm working with a clients on-site SQL Server and an Access front-end

Recently I started getting an error in Access when I attempted to write to one of the tables in the database.  I was unable to resolve this issue from within Access so I turned to SSMS and now when I run this query
SELECT TOP 1000 *
from tbl_Cygnet_Readings_Frequent 
order by report_DT
I get the error:
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command.  The results, if any, should be discarded.
I'm able to run:
SELECT TOP 5 * from tbl_Cygnet_Readings_Frequent 
and get these results.
ID     FacilityID	Report_DT                 PDIFF      PSTATIC    RGAS       LastModified               SSMA_Timestamp        TMPGAS
3198031   10521	2018-04-20 20:49:00.097   40.61012   817.1606   1917.925   2018-04-20 20:49:00.097    0x00000000003902E6    74.510755
3197797   10521	2018-04-20 21:30:05.473   42.62617   818.8284   1965.338   2018-04-20 21:30:05.473    0x00000000003901E2    75.17493
3197673   10521	2018-04-20 21:49:35.800   42.16301   819.0925   1953.901   2018-04-20 21:49:35.800    0x0000000000390165    75.59758
3197415   10521	2018-04-20 22:30:05.313   41.17471   819.7466   1930.659   2018-04-20 22:30:05.313    0x000000000039001B    76.0209
3197222   10521	2018-04-20 22:50:40.303   41.18724   820.0338   1932.077   2018-04-20 22:50:40.303    0x000000000038FF4E    75.708015
But when I add an Order By clause containing any field other than FacilityID (nvarchar -20), I get the error mentioned above.

I can filter the data (over 9M records) using a where clause on any of the fields, and can even generate grouped data with queries like:

SELECT cast(Pstatic as integer) as PD2, COUNT(*)
from tbl_Cygnet_Readings_Frequent
WHERE LastModified >= '2020-03-01'
GROUP BY CAST(pstatic as integer)
or
SELECT FacilityID, COUNT(*)
from tbl_Cygnet_Readings_Frequent
WHERE LastModified >= '2020-03-01'
GROUP BY FacilityID
but as soon as I try something that requires a sort, it gives me the same error:
SELECT FacilityID, MAX(LastModified)
FROM tbl_Cygnet_Readings_Frequent
group by FacilityID
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros