Question

I am moving a data pull from Access to SSMS, but the results are not matching. The Access query is:

INSERT INTO EVAL_CORE ( eval_id, status, published, user_id, quality_date, q_percent, max_q_score, tot_q_score, eform_id, hierarchy, last_rev_date, last_activity, evaluator_id )

SELECT dbo_evaluations.eval_id, dbo_evaluations.status, dbo_evaluations.published, dbo_evaluations.user_id, dbo_evaluations.quality_date, dbo_evaluations.q_percent, dbo_evaluations.max_q_score, dbo_evaluations.tot_q_score, dbo_evaluations.eform_id, dbo_evaluations.hierarchy, dbo_evaluations.last_rev_date, dbo_evaluations.last_activity, dbo_evaluations.evaluator_id

FROM FORMS_REF INNER JOIN dbo_evaluations ON FORMS_REF.eform_id = dbo_evaluations.eform_id

WHERE (((dbo_evaluations.status)=4 Or (dbo_evaluations.status)=5) AND ((dbo_evaluations.published)=1) AND ((dbo_evaluations.quality_date) Between [Forms]![FRM_DATA_PULL]![STRT_DATE] And [Forms]![FRM_DATA_PULL]![END_DATE]));

While the SQL query is:

INSERT INTO EVAL_CORE ( [eval_id]

, [status]

, [published]

, [user_id]

, [quality_date]

, [q_percent]

, [max_q_score]

, [tot_q_score]

, [eform_id]

, [hierarchy]

, [last_rev_date]

, [last_activity]

, [evaluator_id] )



SELECT [eval_id]

, [status]

, [published]

, [user_id]

, [quality_date]

, [q_percent]

, [max_q_score]

, [tot_q_score]

, qf.[eform_id]

, [hierarchy]

, [last_rev_date]

, [last_activity]

, [evaluator_id]



FROM [QFINITI].[Qfiniti_Platform].[dbo].[evaluations] qf

INNER JOIN FORMS_REF sr ON qf.eform_id = sr.[eform_id]

WHERE (((qf.[status])=4 Or (qf.[status])=5)

AND ((qf.[published])=1) AND ((qf.[quality_date])

BETWEEN @sdate AND @edate));

Access produces 3000+ records (which is expected) while the SQL query returns about 500, well below what it should be. I don't see where the difference may be.

Was it helpful?

Solution

In Access you are doing

FROM FORMS_REF INNER JOIN dbo_evaluations

In SQL you have it the opposite way around:

FROM [QFINITI].[Qfiniti_Platform].[dbo].[evaluations] qf INNER JOIN FORMS_REF

This probably shouldn't make a difference.

However it does open the question: SQL is querying from a Linked Server [QFINITY]. How like the Access database is the [QFINITY Platform] database on that server?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top