转换为SSMS的访问查询产生的结果较少

时间:2014-01-24 17:42:24

标签: sql tsql ms-access ssms

我正在将数据从Access移动到SSMS,但结果不匹配。 Access查询是:

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]));

虽然SQL查询是:

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生成3000多条记录(这是预期的),而SQL查询返回大约500条记录,远低于它应该的大小。我不知道差异可能在哪里。

1 个答案:

答案 0 :(得分:0)

在Access中你正在做

FROM FORMS_REF INNER JOIN dbo_evaluations

在SQL中你有相反的方式:

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

这可能不应该有所作为。

然而它确实打开了一个问题:SQL正在从链接服务器[QFINITY]查询。 Access数据库与该服务器上的[QFINITY Platform]数据库的相似程度如何?