我的SQL查询是
ALTER procedure [dbo].[proc_PROJECT_CAT_D_LIST]
@USER_ID BIGINT=NULL, @CAT_ID BIGINT=NULL, @DEPT_ID BIGINT=NULL
AS
IF(@CAT_ID > 0 )
BEGIN
SELECT DETAIL_ID, DETAIL_CODE, SPEC_1, SPEC_2, SPEC_3, SPEC_4, CAT_ID
FROM PROJECT_CAT_DETAILS
WHERE CAT_ID=@CAT_ID
END
ELSE
begin
IF(@DEPT_ID IS NULL)
SELECT @DEPT_ID=Dept_Id
FROM Employee_Master
WHERE Emp_Id=@USER_ID
CREATE TABLE #TEMP_DEPT ( DEPT_ID BIGINT, DEPT_NAME VARCHAR(100), PARENT_DEPT BIGINT )
INSERT INTO #TEMP_DEPT
( DEPT_ID, DEPT_NAME, PARENT_DEPT )
EXEC [Dept_List] @DEPT_ID, 1, @USER_ID
SELECT PCD.DETAIL_ID, PCD.DETAIL_CODE,ISNULL(SPEC_1,'')+ ' ' +ISNULL(SPEC_2,'') AS SPECSFI, PCD.SPEC_1, PCD.SPEC_2, PCD.SPEC_3, PCD.SPEC_4, PCD.CAT_ID,P.PROJECT_NAME,PC.CAT_NAME,
P.PROJECT_ID
FROM #TEMP_DEPT T, PROJECTS P, PROJECT_CAT PC, PROJECT_CAT_DETAILS PCD
WHERE T.DEPT_ID=P.DEPT_ID AND P.PROJECT_ID=PC.PROJECT_ID AND PC.CAT_ID=PCD.CAT_ID AND Deleted !=1
ORDER BY PCD.DETAIL_ID DESC
DROP TABLE #TEMP_DEPT
end
答案 0 :(得分:1)
我在sql查询中添加了一个被删除的条件!= 0然后出错 来自
根据您的评论,您似乎使用的是SQL Server 2005之前的版本。
SQL Server 2005 and above上的比较运算符!=
支持。尝试将其更改为<>
运营商。