SQL query working differently in sql plus and SSSR

5 pts.
Tags:
SQL Query
SQL Server
SQL Server Query
SSRS reports
I wrote down a sql query for creating a SSRS report. The query is fetching different no of rows and data in SQLPlus and SSRS. I am worried how same query can fetch different results in different environments.

Please help me.

Answer Wiki

Thanks. We'll let you know when a new response is added.

There are a few things that can cause this.
1. Security – if you have certain roles when running interactively, and SSRS is running under an account with different roles, if there are records that are secured, you may see different results. This is unlikely (requires fairly advanced systems).
2. Environment settings – It is possible to force SQL Server to run queries in case-sensitive mode, which can easily result in different row counts. There are other environment settings that can also cause differences (collation sequences, code sets, etc.).
3. Overloaded T-SQL functions – if SSRS runs with one user account and the user has a different one, it is possible there is a function in the query that exists in both accounts but performs differently.
4. Different databases – again, if SSRS is running with one user role OR database connection, and the user has a different role/connection, the interactive query may be executing against one table (in one database) and SSRS is running against the same table in a different database. This is REALLY easy to encounter if you have multiple copies of databases (for production, test, training, etc.).
When I see inconsistent results, #4 is the first thing I look at – am I sure I am running the query against the same server/catalog/schema/database in both cases?

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    I wouldn't be surprised. The two are from different vendors for different DBMSs. If there is any significant complexity at all, different results should be expected. In addition to items already listed, review the vendors' documentation for each clause in your query statements. Attempt to replace any clauses that have different interpretations from the vendors with alternatives that have more standard SQL meanings. If it needs to work in different environments, then it needs to be standardized. Don't use vendor extensions nor features with unique implementations. Look for standard SQL as much as possible first. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following