sql server alwayson Returns the result difference from singel instance

jiajun su 1 Reputation point
2022-12-28T13:52:54.637+00:00

When we execute a stored procedure, we find that the results of the SQL Server stand-alone and alwayson queries are different, and there are more results.
sqlserver 2005 single instance:
274508-image.png

sqlserver 2016 single instance:
274515-image.png

sqlserver 2016 alwayson:
274516-image.png

This difference leads to alwayson execution when use jdbc driver:
[INFO] [2022-12-26 12:27:32,386] [logid:32cd4b40eb2d429b8c27d143c2468793] [sessionId:6E09147B978936DAE6000DAFBDF45F7F] com.citic.crm.ncrm.dao.complaint.ComplaintDaoImpl.dealComplaint(ComplaintDaoImpl.java:1452) -投诉单投诉单操作(审核/经办/复核/结案)sql:{?=call dbo.sp_ComplainList_JinBan (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}
[ERROR] [2022-12-26 12:27:32,387] [logid:32cd4b40eb2d429b8c27d143c2468793] [sessionId:6E09147B978936DAE6000DAFBDF45F7F] com.citic.crm.ncrm.dao.complaint.ComplaintDaoImpl.dealComplaint(ComplaintDaoImpl.java:1476) -投诉单投诉单操作(审核/经办/复核/结案)时出现异常:java.sql.SQLException: Output parameters have not yet been processed. Call getMoreResults().
java.sql.SQLException: Output parameters have not yet been processed. Call getMoreResults().
at net.sourceforge.jtds.jdbc.ParamInfo.getOutValue(ParamInfo.java:159)
at net.sourceforge.jtds.jdbc.JtdsCallableStatement.getOutputValue(JtdsCallableStatement.java:115)

Why this discrepancy?

SQL Server Migration Assistant
SQL Server Migration Assistant
A Microsoft tool designed to automate database migration to SQL Server from Access, DB2, MySQL, Oracle, and SAP ASE.
568 questions
SQL Server Other
{count} votes

2 answers

Sort by: Most helpful
  1. Bjoern Peters 8,921 Reputation points
    2022-12-28T14:27:28.777+00:00

    Hi @jiajun su

    make sure the configuration for each session in SSMS is the same and please post the same screenshot for the last result (2016 AO) with active tab on the text results...

    Are you 100% sure that all data on all machines is the same?
    What about database compat level on those three databases? Are they the same?

    That screenshot of 2016 AO doesn't mean that there are more results, it just shows you a resultset as a grid... as Yitzhak already stated, we need to see your DDL for the proc to understand the output... your results on 2005 and 2016 seems to be the same (0,0,1)... so there is at least one row as a result... and maybe it is just a difference in the optical view in SSMS and the text output says the same as on the other instances...

    I hope my answer is helpful to you,

    Your
    Bjoern Peters

    If the reply was helpful, please upvote and/or accept it as an answer, as this helps others in the community with similar questions. Thanks!


  2. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2022-12-28T22:24:28.157+00:00

    Obvious possible reasons for the differences:

    1) Different code in the different databases.
    2) Different data in the different databases.

    The fact that one database is in an availability group as such has nothing to do with it. Although, hypothetically, the SP may be coded in such a way that it produces a result set if you are in an AG. But the reason for the unexpected result set is likely to be something else, for instance a stray debug SELECT. You will need to look at the code.

    You real problem seems to be the failing Java code, and the error message is very clear:

    java.sql.SQLException: Output parameters have not yet been processed. Call getMoreResults().

    And that is exactly what you need. Whatever API you are using, you should always ask to get the next result set until you get a negative answer. You should never make an assumption that you only have a certain number of result set. Not only because you can get error because of unexpected SELECT, but you can also miss exceptions from the SQL code this way.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.