求解 无法绑定由多个部分组成的标识符???
我有个存储过程,传参进入就报错。
但是我直接查询语句是可以执行的。求解啊?
分页的,我Where条件传
t_TaskDetail.DataMark in(1,4,6) and t_ReturnVisit.CreateTime >='2013-05-01' and t_ReturnVisit.CreateTime <'2013-05-11 23:59:59' 就报无法绑定由多个部分组成的标识符[t_ReturnVisit.CreateTime]的错,
但是我直接执行
SELECT t_TaskDetail.ID AS ID,
t_TaskDetail.TaskEmpNo AS TaskEmpNo,
t_TaskDetail.Planner AS Planner,
t_TaskDetail.IsReturn AS IsReturn,
t_TaskDetail.EndTime AS EndTime,
t_ErrorDetail.Title AS Title,
t_ErrorDetail.CreateTime AS BeginTime,
t_ErrorDetail.Declarer AS Declarer,
t_ErrorDetail.OrgNo AS OrgNo,
t_ErrorDetail.TelNum AS TelNum,
t_ErrorDetail.MobileNum AS MobileNum,
t_ErrorDetail.Location AS Location,
t_ReturnVisit.CreateTime AS ReturnTime
FROM t_ReturnVisit right join t_ErrorDetail INNER JOIN
t_TaskDetail ON t_ErrorDetail.ID = t_TaskDetail.ErrorID on
(dbo.t_TaskDetail.ID = dbo.t_ReturnVisit.TaskID)
where t_TaskDetail.DataMark in(1,4,6) and t_ReturnVisit.CreateTime >='2013-05-01' and t_ReturnVisit.CreateTime <'2013-05-11 23:59:59'
是可以执行的,
存储过程如下:
ALTER PROCEDURE [dbo].[p_TaskReturn_List2]
@FieldsClause VARCHAR(2000) = NULL, --查询列子句
@WhereClause VARCHAR(2000) = NULL, --查询条件子句
@OrderClause VARCHAR(2000) = NULL, --查询排序子句
@PageSize INT = 0, -- 分页查询的每页数量,为0表示查询全部,不分页。
@PageNumber INT = 1, -- 分页查询的当前页号
@TotalSize INT OUTPUT, -- 返回值,查询结果记录条数
@TotalPage INT OUTPUT -- 返回值,查询结果总页数
AS
BEGIN
SET NOCOUNT ON
-- 声明变量
DECLARE @Sql NVARCHAR(4000) -- 用于保存动态组织的sql语句
DECLARE @ParmDefinition NVARCHAR(500) -- 用于保存临时参数
DECLARE @MinRowIndex INT -- 分页查询的最小行号
DECLARE @MaxRowIndex INT -- 分页查询的最大行号
-- 检查参数合法性,并设置为可用值
SET @FieldsClause = LTRIM(RTRIM(ISNULL(@FieldsClause,'*'))) -- 缺省查询所有字段
SET @WhereClause = LTRIM(RTRIM(ISNULL(@WhereClause,'')))
SET @OrderClause = LTRIM(RTRIM(ISNULL(@OrderClause,'')))
IF(@OrderClause = '') SET @OrderClause = '[ID]'
IF(@PageSize < 0) SET @PageSize = 0
IF(@PageNumber < 1) SET @PageNumber = 1
IF(@PageSize = 0) -- 为0表示不分页
BEGIN
-- 如果不分页
-- 组织查询语句
SET @Sql = N'
SELECT t_TaskDetail.ID AS ID,
t_TaskDetail.TaskEmpNo AS TaskEmpNo,
t_TaskDetail.Planner AS Planner,
t_TaskDetail.IsReturn AS IsReturn,
t_TaskDetail.EndTime AS EndTime,
t_ErrorDetail.Title AS Title,
t_ErrorDetail.CreateTime AS BeginTime,
t_ErrorDetail.Declarer AS&nb