在SSRS中处理查询,当我使用@Date参数时,它似乎无法正常工作,我没有收到错误,但它没有返回值。当我取出= @ Date值时,似乎运行正常。关于如何纠正这个问题的任何想法?我希望能够输入姓名和日期。
由于
SELECT TOP (100) PERCENT A.__$start_lsn, A.__$seqval, A.__$operation, A.__$update_mask, A.t_Refcntd, A.t_Refcntu, A.t_cbrn, A.t_ccon, A.t_ccor, A.t_ccrs, A.t_ccty, A.t_ccur,
A.t_cdec, A.t_cfrw, A.t_cfsg, A.t_clan, A.t_comp, A.t_corg, A.t_cotp, A.t_cpay, A.t_cplp, A.t_creg, A.t_ctrj, A.t_cvyn, A.t_cwar, A.t_ddat, A.t_ddtc, A.t_egen, A.t_odat,
A.t_odis, A.t_orno, A.t_prno, A.t_pspr, A.t_pstx, A.t_ragr, A.t_ratf, A.t_ratp, A.t_refa, A.t_refb, A.t_suno, A.t_txta, A.t_txtb, A.tran_begin_time, A.tran_end_time,
B.event_time, B.event_time_local, B.sequence_number, B.action_id, B.succeeded, B.permission_bitmask, B.is_column_permission, B.session_id,
B.server_principal_id, B.database_principal_id, B.target_server_principal_id, B.target_database_principal_id, B.object_id, B.class_type,
B.session_server_principal_name, B.server_principal_name, B.server_principal_sid, B.database_principal_name, B.target_server_principal_name,
B.target_server_principal_sid, B.target_database_principal_name, B.server_instance_name, B.database_name, B.schema_name, B.object_name, B.statement,
B.additional_information, B.file_name, B.audit_file_offset, CONVERT(VARCHAR(10), A.tran_end_time, 110) AS GenericDate
FROM dbo.ttdpur040101_CT AS A INNER JOIN
dbo.ttdpur040101_Audit AS B ON NOT (A.tran_begin_time > B.event_time_local OR
A.tran_end_time < B.event_time_local) AND (A.__$operation = 2 AND B.action_id = 'IN' OR
(A.__$operation = 3 OR
A.__$operation = 4) AND B.action_id = 'UP' OR
A.__$operation = 1 AND B.action_id = 'DL') AND B.class_type = 'U'
WHERE (B.server_principal_name = @Name) and (CONVERT(VARCHAR(10), A.tran_end_time, 110) = @Date)
ORDER BY B.event_time_local
答案 0 :(得分:1)
如果要比较它们,格式需要匹配。将您的WHERE更改为:
WHERE (B.server_principal_name = @Name)
and (CONVERT(VARCHAR(10), A.tran_end_time, 110) = (CONVERT(VARCHAR(10),@Date, 110))