Sunday, February 19, 2012

Error - Application uses a value of the wrong type for the current operation

I have a sql statement using MS SQL Server as follows
SELECT TowerNumber, TowerNumber AS CountEntriesPerTowerNumber
FROM tblTowers
WHERE (ReadingDate BETWEEN @.BeginningMonth AND @.EndingMonth) AND
(LocationID = @.LocationID) AND (SystemID = @.SystemID)
ORDER BY LocationID, SystemID, TowerNumber
When I use the same query and add group by, I get the error - Application
uses a value of the wrong type for the current operation
SELECT TowerNumber, COUNT(TowerNumber) AS CountEntriesPerTowerNumber
FROM tblTowers
WHERE (ReadingDate BETWEEN @.BeginningMonth AND @.EndingMonth)
GROUP BY TowerNumber, LocationID, SystemID
HAVING (LocationID = @.LocationID) AND (SystemID = @.SystemID)
ORDER BY LocationID, SystemID, TowerNumber
How do I get past this error?
ThanksHi,
Have u used any variable with datatype uniqueidentifier.If yes then
change the datatype.
from
Doller|||Not using uniqueidentifier.
I do have a field that is an identity field but it is not in the query and I
have never run into this before.
Plus the first query does work the second does not.
"doller" <sufianarif@.gmail.com> wrote in message
news:1128420745.167906.89260@.o13g2000cwo.googlegroups.com...
> Hi,
> Have u used any variable with datatype uniqueidentifier.If yes then
> change the datatype.
> from
> Doller
>|||Hi Craig,
Welcome to use MSDN Managed Newsgroup!
From your descriptions, I understood adding GROUP BY will lead to the error
message "Application uses a value of the wrong type for the current
operation". If I have misunderstood your concern, please feel free to point
it out.
Based on my knowledge, this could be caused by various reasons and let
perform the troubleshooting step by step.
1. Check the length of parameters. The error could if the length of the
data passed to the parameter exceeds the
maximum size of the parameter or field.
2. Use the Profiler to trace what was inserted into SQL Server
3. If we replace all the parameters with real value and execute the
replaced statements in Query Analyzer, will it report the error message?
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment