请帮我解决错误。 [英] please help me to solve the errors.

查看:81
本文介绍了请帮我解决错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   case 我是过程中使用  执行我的查询时出现以下错误请帮我 解决它们。 

case vch_Remarks Null 选择 vch_Remarks 来自 T_CAF_Receive C 其中 C.vch_UniqueRefNo = A.vch_UniqueRefNo ISNULL(c.bit_DeletedFlag, 0 )= 0) else select vch_remarks 来自 M_Remark_Detail 其中 int_Remark_id in 选择 val 来自 UDF_Split(选择 vch_Remarks from T_Caf_Receive 其中​​ C.vch_UniqueRefNo = A.vch_UniqueRefNo ISNULL(c.bit_DeletedFlag, 0 )= 0))) end 作为 vch_Remarks

错误是Msg 156 ,Level 15 ,状态 1 ,行 1 关键字'
case'。消息 156 ,级别 15 ,状态 1 ,Line 4 关键字' else'<附近的语法不正确/跨度>。消息 156 ,级别 15 ,状态 1 ,Line 5 关键字附近的语法不正确' 选择'< /跨度>。消息 102 ,等级 15 ,状态 1 ,Line 6 ' )'。





我的完整程序是





 CREATE PROCEDURE [dbo]。[USP_ViewRejectedReport] 


@Pvch_AdvertisementNo varchar(200),
@Pvch_Post_Code varchar(100),
@Pint_DistrictId int,
@PintType int


as
begin
If(@PintType = 1)
Begin
If(@Pint_DistrictId = 0)
开始
选择A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender当1然后'Male'当2然后'Female'结束为Gender, vch_CorHouseNo,(从M_District中选择vch_DistrictName,其中int_DistrictID = A.int_CorDistID和int_StateID = A.int_CorStateI D)区,vch_CorPinCode,dtm_DOB,(情况int_CategoryId当1然后'UR'当2然后'SC'当3然后'ST'时4然后'SEBC'结束)类别,(case isnull(bit_PHOH,0)当1然后'是'否则'否'结束)PWD,(case isnull(bit_SportsPerson,0)当1然后'是'否则'否'结束)SportsPerson,(case isnull(bit_ESM,0)当1然后'是'否则'否' '结束)ESM,(case isnull(bit_Odia,0)当1然后'是'否则'否'结束)Odia,(从T_Finance_Details F中选择vch_DDNO,其中isnull(F.bit_DeletedFlag,0)= 0和F.vch_uniquerefno = A .vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,(从T_CAF_Receive C中选择vch_Remarks,其中C.vch_UniqueRefNo = A.vch_UniqueRefNo和ISNULL(c.bit_DeletedFlag,0)= 0)vch_Remarks,(case isnull(A.bit_ReceiveStatus,0)当1然后'1'否则'0'结束)来自T_ApplicantDetails_Temp的ReceiveStatus A其中isnull(A.bit_DeletedFlag,0)= 0且ISNULL(A.bit_ReceiveStatus,0)= 1且ISNULL(A.bit_Rejected,0)= 1且isnull(A .bit_Duplica teStatus,0)= 0和A.vch_AdvertisementNo = @Pvch_AdvertisementNo和A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
End
Else
开始
选择A.int_ApplicantId,A .vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender当1然后'Male'当2然后'Female'结束为Gender,vch_CorHouseNo,(从M_District选择vch_DistrictName,其中int_DistrictID = A.int_CorDistID和int_StateID = A.int_CorStateID)区,vch_CorPinCode,dtm_DOB ,(case int_CategoryId当1然后'UR'当2然后'SC'当3然后'ST'当4然后'SEBC'结束时)类别,(case isnull(bit_PHOH,0)当1然后'是'否则'否'结束)PWD,(case isnull(bit_SportsPerson,0)当1然后'是'否则'否'结束)SportsPerson,(case isnull(bit_ESM,0)当1然后'是'否则'否'结束)ESM,(case isnull(bit_Odia,0)当1然后'是'否则'否'结束)Odia,(从T_Finance_Det选择vch_DDNO) ails F where isnull(F.bit_DeletedFlag,0)= 0和F.vch_uniquerefno = A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,(从T_CAF_Receive C中选择vch_Remarks,其中C.vch_UniqueRefNo = A.vch_UniqueRefNo和ISNULL(c.bit_DeletedFlag,0 )= 0)vch_Remarks,(case isnull(A.bit_ReceiveStatus,0)当1然后'1',否则'0'结束)来自T_ApplicantDetails_Temp的ReceiveStatus A其中isnull(A.bit_DeletedFlag,0)= 0和ISNULL(A.bit_ReceiveStatus, 0)= 1和ISNULL(A.bit_Rejected,0)= 1并且isnull(A.bit_DuplicateStatus,0)= 0和A.vch_AdvertisementNo =@Pvch_AdvertisementNo和A.vch_Post_Code=@Pvch_Post_Code和A.int_examDistrictId=@Pint_DistrictId由A命令.vch_UniqueRefNo
结束
结束

否则If(@PintType = 2)
开始
If(@Pint_DistrictId = 0)
开始

选择A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1然后'男'当2然后'女'结束为性别,vch_CorHouseNo,(从M_District选择vch_DistrictName,其中int_DistrictID = A.int_CorDistID和int_StateID = A.int_CorStateID)区,vch_CorPinCode,dtm_DOB,(情况int_CategoryId当1然后'UR'当2然后'SC'当3然后'ST'当4然后'SEBC'结束)类别,(case isnull(bit_PHOH,0)当1然后'是'否则'否'结束)PWD,(case isnull(bit_SportsPerson, 0)当1然后'是'否则'否'结束)SportsPerson,(case isnull(bit_ESM,0)当1然后'是'否则'否'结束)ESM,(case isnull(bit_Odia,0)当1然后'是'其他'否'结束)Odia,(从T_Finance_Details F中选择vch_DDNO,其中isnull(F.bit_DeletedFlag,0)= 0和F.vch_uniquerefno = A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,(从T_CAF_Receive C中选择vch_Remarks,其中C .vch_UniqueRefNo = A.vch_UniqueRefNo和ISNULL(c.bit_DeletedFlag,0)= 0)vch_Remarks,(case isnull(A.bit_ReceiveStatus,0)当1然后'1'其他' 0'结束)来自T_ApplicantDetails_Temp的ReceiveStatus A其中isnull(A.bit_DeletedFlag,0)= 0且ISNULL(A.bit_ReceiveStatus,0)= 1且ISNULL(A.bit_Rejected,0)= 1且isnull(A.bit_DuplicateStatus,0) = 0和A.vch_AdvertisementNo = @Pvch_AdvertisementNo和A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
End
Else
开始
选择A.int_ApplicantId,A.vch_UniqueRefNo,A .vch_ApplicantName,case int_Gender当1然后'Male'当2然后'Female'结束为Gender,vch_CorHouseNo,(从M_District选择vch_DistrictName,其中int_DistrictID = A.int_CorDistID和int_StateID = A.int_CorStateID)区,vch_CorPinCode,dtm_DOB,(case int_CategoryId当1然后'UR'当2然后'SC'当3然后'ST'当4然后'SEBC'结束)类别,(case isnull(bit_PHOH,0)当1然后'是'否则'否'结束)PWD, (case isnull(bit_SportsPerson,0)当1然后'是'否则'否'结束)SportsPerson,( case isnull(bit_ESM,0)当1然后'是'否则'否'结束)ESM,(case isnull(bit_Odia,0)当1然后'是'否则'否'结束)Odia,(从T_Finance_Details F中选择vch_DDNO,其中isnull(F.bit_DeletedFlag,0)= 0和F.vch_uniquerefno = A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,(从T_CAF_Receive C中选择vch_Remarks,其中C.vch_UniqueRefNo = A.vch_UniqueRefNo和ISNULL(c.bit_DeletedFlag,0)= 0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0)当1然后'1',否则'0'结束)来自T_ApplicantDetails_Temp的ReceiveStatus A其中isnull(A.bit_DeletedFlag,0)= 0和ISNULL(A.bit_ReceiveStatus,0)= 1和ISNULL(A.bit_Rejected,0)= 1和isnull(A.bit_DuplicateStatus,0)= 0和A.vch_AdvertisementNo =@Pvch_AdvertisementNo和A.vch_Post_Code =@Pvch_Post_Code和A.int_examDistrictId =@Pint_DistrictId由A.vch_UniqueRefNo $订购b $ b结束
结束
否则如果(@PintType = 3)
开始
如果(@ Pint_DistrictId = 0)
开始
选择A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender当1然后'Male'当2然后'Female'结束为Gender,vch_CorHouseNo,(从中选择vch_DistrictName M_District其中int_DistrictID = A.int_CorDistID和int_StateID = A.int_CorStateID)区,vch_CorPinCode,dtm_DOB,(情况int_CategoryId当1然后'UR'当2然后'SC'当3然后'ST'时4'然后'SEBC'结束)类别,(case isnull(bit_PHOH,0)当1然后'是'否则'否'结束)PWD,(case isnull(bit_SportsPerson,0)当1然后'是'否则'否'结束)SportsPerson,(case isnull(bit_ESM) ,0)当1然后'是'否则'否'结束)ESM,(case isnull(bit_Odia,0)当1然后'是'否则'否'结束)Odia,(从T_Finance_Details F中选择vch_DDNO,其中isnull(F。 bit_DeletedFlag,0)= 0和F.vch_uniquerefno = A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,(从T_CAF_Receive中选择vch_Remarks C其中C.vch_UniqueRefNo = A.vch_UniqueRefNo和ISNULL(c.bit_DeletedFlag,0)= 0)vch_Remarks,(case isnull(A.bit_ReceiveStatus,0)当1然后'1'否则'0'结束)来自T_ApplicantDetails_Temp A的ReceiveStatus其中isnull(A.bit_DeletedFlag,0)= 0和ISNULL(A.bit_ReceiveStatus,0)= 1和ISNULL(A.bit_Rejected,0)= 1且isnull(A.bit_DuplicateStatus,0)= 0和A.vch_AdvertisementNo = @Pvch_AdvertisementNo和A.vch_Post_Code=@Pvch_Post_Code的顺序由A.vch_UniqueRefNo
结束
否则
开始
选择A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender当1然后'男性'当2然后'女性'结束为性别,vch_CorHouseNo,(从M_District选择vch_DistrictName,其中int_DistrictID = A.int_CorDistID和int_StateID = A.int_CorStateID)区,vch_CorPinCode,dtm_DOB,(情况int_CategoryId当1然后'UR'当2然后'SC'当3然后'ST'时4然后'SEBC'结束)类别,(cas e isnull(bit_PHOH,0)当1然后'是'否则'否'结束)PWD,(case isnull(bit_SportsPerson,0)当1然后'是'否则'否'结束)SportsPerson,(case isnull(bit_ESM,0 )当1然后'是'否则'否'结束)ESM,(case isnull(bit_Odia,0)当1然后'是'否则'否'结束)Odia,(从T_Finance_Details F中选择vch_DDNO,其中isnull(F.bit_DeletedFlag, 0)= 0和F.vch_uniquerefno = A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,(从T_CAF_Receive C中选择vch_Remarks,其中C.vch_UniqueRefNo = A.vch_UniqueRefNo和ISNULL(c.bit_DeletedFlag,0)= 0)vch_Remarks,(case isnull (A.bit_ReceiveStatus,0)当1然后'1'否则'0'结束)来自T_ApplicantDetails_Temp的ReceiveStatus A其中isnull(A.bit_DeletedFlag,0)= 0和ISNULL(A.bit_ReceiveStatus,0)= 1和ISNULL(A。 A.vch_UniqueRe的bit_Rejected,0)= 1和isnull(A.bit_DuplicateStatus,0)= 0和A.vch_AdvertisementNo =@Pvch_AdvertisementNo和A.vch_Post_Code =@Pvch_Post_Code和A.int_examDistrictId =@Pint_DistrictId order fNo
结束

结束
否则If(@PintType = 4)
开始
If(@Pint_DistrictId = 0)
开始
选择A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender当1然后'Male'当2然后'Female'结束为Gender,vch_CorHouseNo,(从M_District中选择vch_DistrictName,其中int_DistrictID = A.int_CorDistID和int_StateID = A .int_CorStateID)区,vch_CorPinCode,dtm_DOB,(情况int_CategoryId当1然后'UR'当2然后'SC'当3然后'ST'时4然后'SEBC'结束)类别,(case isnull(bit_PHOH,0)当1然后'是'否则'否'结束)PWD,(case isnull(bit_SportsPerson,0)当1然后'是'否则'否'结束)SportsPerson,(case isnull(bit_ESM,0)当1然后'是'else'没有'结束'ESM,(case isnull(bit_Odia,0)当1然后'是'否则'否'结束)Odia,(从T_Fin选择vch_DDNO) ance_Details F其中isnull(F.bit_DeletedFlag,0)= 0和F.vch_uniquerefno = A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,(从T_CAF_Receive C中选择vch_Remarks,其中C.vch_UniqueRefNo = A.vch_UniqueRefNo和ISNULL(c.bit_DeletedFlag,0 )= 0)vch_Remarks,(case isnull(A.bit_ReceiveStatus,0)当1然后'1',否则'0'结束)来自T_ApplicantDetails_Temp的ReceiveStatus A其中isnull(A.bit_DeletedFlag,0)= 0和ISNULL(A.bit_ReceiveStatus, 0)= 1和ISNULL(A.bit_Rejected,0)= 1并且isnull(A.bit_DuplicateStatus,0)= 0和A.vch_AdvertisementNo = @Pvch_AdvertisementNo和A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
End
Else
开始
选择A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender当1然后'Male'当2然后'Female'结束为Gender,vch_CorHouseNo,(选择vch_DistrictName来自M_District,其中int_DistrictID = A.int_CorDistID和int_StateID = A.int_CorStateI D)区,vch_CorPinCode,dtm_DOB,(情况int_CategoryId当1然后'UR'当2然后'SC'当3然后'ST'时4然后'SEBC'结束)类别,(case isnull(bit_PHOH,0)当1然后'是'否则'否'结束)PWD,(case isnull(bit_SportsPerson,0)当1然后'是'否则'否'结束)SportsPerson,(case isnull(bit_ESM,0)当1然后'是'否则'否' '结束)ESM,(case isnull(bit_Odia,0)当1然后'是'否则'否'结束)Odia,(从T_Finance_Details F中选择vch_DDNO,其中isnull(F.bit_DeletedFlag,0)= 0和F.vch_uniquerefno = A .vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,(从T_CAF_Receive C中选择vch_Remarks,其中C.vch_UniqueRefNo = A.vch_UniqueRefNo和ISNULL(c.bit_DeletedFlag,0)= 0)vch_Remarks,(case isnull(A.bit_ReceiveStatus,0)当1然后'1'否则'0'结束)来自T_ApplicantDetails_Temp的ReceiveStatus A其中isnull(A.bit_DeletedFlag,0)= 0且ISNULL(A.bit_ReceiveStatus,0)= 1且ISNULL(A.bit_Rejected,0)= 1且isnull(A .bit_Duplica teStatus,0)= 0和A.vch_AdvertisementNo=@Pvch_AdvertisementNo和A.vch_Post_Code=@Pvch_Post_Code和A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
End
End
Else
开始
If(@Pint_DistrictId = 0)
开始
选择A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender当1然后'Male'当2然后'Female'结束作为Gender,vch_CorHouseNo,(从M_District中选择vch_DistrictName,其中int_DistrictID = A.int_CorDistID和int_StateID = A.int_CorStateID)区,vch_CorPinCode,dtm_DOB,(情况int_CategoryId当1然后'UR'当2然后'SC'当3然后'ST'当4然后'SEBC'结束)类别,(case isnull(bit_PHOH,0)当1然后'是'否则'否'结束)PWD,(case isnull(bit_SportsPerson,0)当1然后'是'否则'否'结束)SportsPerson,(case isnull(bit_ESM,0)当1然后'是'否则'否'结束)ESM,(case isnull(bit_Odia,0)当1然后'是'否则'否'结束)Odia,(从T_Finance_Details F中选择vch_DDNO,其中isnull(F.bit_DeletedFlag,0)= 0和F.vch_uniquerefno = A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,(从T_CAF_Receive C中选择vch_Remarks,其中C.vch_UniqueRefNo = A.vch_UniqueRefNo和ISNULL(c.bit_DeletedFlag,0)= 0)vch_Remarks,(case isnull(A.bit_ReceiveStatus,0)when 1然后'1'否则'0'结束)来自T_ApplicantDetails_Temp的ReceiveStatus A其中isnull(A.bit_DeletedFlag,0)= 0且ISNULL(A.bit_ReceiveStatus,0)= 1且ISNULL(A.bit_Rejected,0)= 1且isnull (A.bit_DuplicateStatus,0)= 0和A.vch_AdvertisementNo = @Pvch_AdvertisementNo和A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
End
Else
开始
选择A. int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender当1然后'Male'当2然后'Female'结束为Gender,vch _CorHouseNo,(从M_District选择vch_DistrictName,其中int_DistrictID = A.int_CorDistID和int_StateID = A.int_CorStateID)区域,vch_CorPinCode,dtm_DOB,(情况int_CategoryId为1然后'UR'为2然后'SC'为3然后'ST'为4然后'SEBC'结束)类别,(case isnull(bit_PHOH,0)当1然后'是'否则'否'结束)PWD,(case isnull(bit_SportsPerson,0)当1然后'是'否则'否'结束)SportsPerson ,(case isnull(bit_ESM,0)当1然后'是'否则'否'结束)ESM,(case isnull(bit_Odia,0)当1然后'是'否则'否'结束)Odia,(从T_Finance_Details中选择vch_DDNO) F其中isnull(F.bit_DeletedFlag,0)= 0和F.vch_uniquerefno = A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,(从T_CAF_Receive C中选择vch_Remarks,其中C.vch_UniqueRefNo = A.vch_UniqueRefNo和ISNULL(c.bit_DeletedFlag,0) = 0)vch_Remarks,(case isnull(A.bit_ReceiveStatus,0)当1然后'1',否则'0'结束)来自T_ApplicantDetails_Temp的ReceiveStatus e isnull(A.bit_DeletedFlag,0)= 0且ISNULL(A.bit_ReceiveStatus,0)= 1且ISNULL(A.bit_Rejected,0)= 1且isnull(A.bit_DuplicateStatus,0)= 0且A.vch_AdvertisementNo = @ P.vch_UniqueRefNo
结束
结束

结束

h2_lin>解决方案

试试这个,我想最后的括号是缺失的

sq

 case  vch_Remarks    Null  然后 
选择 vch_Remarks 来自 T_CAF_Receive C 其中 C.vch_UniqueRefNo = A.vch_UniqueRefNo ISNULL(c.bit_DeletedFlag, 0 )= 0)
else
select vch_remarks From M_Remark_Detail 中的关键字> where int_Remark_id 选择 val 来自 UDF_Split(选择 vch_Remarks 来自 T_Caf_Receive 其中 C.vch_UniqueRefNo = A.vch_UniqueRefNo ISNULL(c.bit_DeletedFlag, 0 )= 0))
结束作为 vch_Remarks


  CREATE   PROCEDURE  [dbo]。[ USP_ViewRejectedReport] 


@ Pvch_AdvertisementNo varchar 200 ),
@ Pvch_Post_Code varchar 100 ),
@ Pint_DistrictId int
@ PintType int


as
开始
如果 @ PintType = 1
开始
如果 @ Pint_DistrictId = 0
开始
选择 A.int_ApplicantId,A .vch_UniqueRefNo,A.vch_ApplicantName, case int_Gender 1 然后 ' 男性' 何时 2 然后 ' < span class =code-string> Female' end as Gender,vch_CorHouseNo,( 选择 vch_DistrictName 来自 M_District 其中 int_DistrictID = A .int_CorDistID int_StateID = A.int_CorStateID)区,vch_CorPinCode,dtm_DOB,( case int_CategoryId 1 然后 ' UR' 2 然后 ' SC' 3 然后 ' ST' 4 ' SEBC' 结束)类别,( case isnull(bit_PHOH, 0 1 然后 ' 是' else ' 否' end )PWD,( case isnull(bit_SportsPerson, 0 1 然后 ' 是' 否则 ' No' end )SportsPerson,( case isnull(bit_ESM, 0 when 1 然后 ' < span class =code-string> Yes' else ' 否' 结束)ESM,( case isnull(bit_Odia,<温泉n class =code-digit> 0 ) 1 then ' 是' else ' No' end )Odia,(选择 vch_DDNO 来自 T_Finance_Details F 其中 isnull(F.bit_DeletedFlag, 0 )= 0 F.vch_uniquerefno = A.vch_uniquerefno )vch_DDNO,A.vch_CorMobileNo,(选择 vch_Remarks 来自 T_CAF_Receive C 其中 C.vch_UniqueRefNo = A.vch_UniqueRefNo ISNULL(c.bit_DeletedFlag, 0 ) = 0)vch_Remarks,( case isnull(A.bit_ReceiveStatus, 0 何时 1 ' 1' else ' 0' end )ReceiveStatus 来自 T_ApplicantDetails_Temp A 其中 isnull(A.bit_DeletedFlag, 0 )= 0 ISNULL(A.bit_ReceiveStatus , 0 )= 1 ISNULL(A.bit_Rejected, 0 )= 1 isnull(A.bit_DuplicateStatus, 0 )= 0 A.vch_AdvertisementNo = @Pvch_AdvertisementNo A.vch_Post_Code=@Pvch_Post_Code order A.vch_UniqueRefNo
结束
其他
开始
选择 A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,< span class =code-keyword> case int_Gender 1 then ' 男性' 2 然后 ' 女性 结束 Gende r,vch_CorHouseNo,(选择 vch_DistrictName 来自 M_District 其中 int_DistrictID = A.int_CorDistID int_StateID = A.int_CorStateID)区,vch_CorPinCode,dtm_DOB,( case int_CategoryId 1 然后 ' UR' 2 然后 ' SC' 3 然后 ' ST' 4 然后 ' SEBC' end )类别,( case isnull(bit_PHOH, 0 何时 1 然后 ' 是' 其他 ' < span class =code-string> No' end )PWD,( case isnull (bit_SportsPerson, 0 1 < span class =code-keyword>然后 ' 是' else ' No' )SportsPerson,( case isnull(bit_ESM, 0 when 1 然后 ' < span class =code-string> Yes' else ' 否' 结束)ESM,( case isnull(bit_Odia,< span class =code-digit> 0 ) 1 then ' 是' else ' No' end )Odia,(选择 vch_DDNO 来自 T_Finance_Details F 其中 isnull(F.bit_DeletedFlag, 0 )= 0 F.vch_uniquerefno = A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo, case vch_Remarks 何时 Null 然后选择 vch_Remarks from T_CAF_Receive C 其中​​ C.vch_UniqueRefNo = A.vch_UniqueRefNo ISNULL( c.bit_DeletedFlag, 0 )= 0) else select vch_remarks 来自 M_Remark_Detail 其中 int_Remark_id 选择 val 来自 UDF_Split(Select vch_Remarks from T_Caf_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(C.bit_DeletedFlag,0)=0))) end As vch_Remarks ,(case isnull(A.bit_ReceiveStatus,0) when 1 then '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A where isnull(A.bit_DeletedFlag,0)=0 a nd ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
End
End

Else If (@PintType = 2)
Begin
If (@Pint_DistrictId = 0)
Begin

select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female' end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then 'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then 'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0) when 1 then 'Yes' else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia, (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO, A.vch_CorMobileNo, ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
End
Else
Begin
select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female' end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then 'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) whe n 1 then 'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0) when 1 then 'Yes' else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia, (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,case vch_Remarks when Null then (select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0)else (select vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(C.bit_DeletedFlag,0)=0))) end As vch_Remarks ,(case isnull(A.bit_ReceiveStatus,0) when 1 then '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
End
End
Else If (@PintType = 3)
Begin
If (@Pint_DistrictId = 0)
Begin
select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female' end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then 'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then 'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0) when 1 then 'Yes' else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia, (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO, A.vch_CorMobileNo, ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
End
Else
Begin
select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female' end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then 'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then 'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0) when 1 then 'Yes' else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia, (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,case vch_Remarks when Null then (select vch_ Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0)else (select vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(C.bit_DeletedFlag,0)=0))) end As vch_Remarks ,(case isnull(A.bit _ReceiveStatus,0) when 1 then '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Co de=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
End

End
Else If (@PintType = 4)
Begin
If (@Pint_DistrictId = 0)
Begin
select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female' end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then 'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_S portsPerson,0) when 1 then 'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0) when 1 then 'Yes' else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia, (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO, A.vch_CorMobileNo, ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
End
Else
Begin
select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female' end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then 'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then 'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0) when 1 then 'Yes' else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia, (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,case vch_Remarks when Null then (select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0)else (select vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(C.bit_DeletedFlag,0)=0))) end As vch_Remarks ,(case isnull(A.bit_ReceiveStatus,0) when 1 then '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and I SNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
End
End
Else
Begin
If (@Pint_DistrictId = 0)
Begin
select A.int_Appl icantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female' end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then 'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then 'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0) when 1 then 'Yes' else 'No' end ) ESM, (case
isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia, (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO, A.vch_CorMobileNo, ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
End
Else
Begin
select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female' end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then 'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then 'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0) when 1 then 'Yes' else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia, (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,case vch_Remarks when Null then (select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0)else (select vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(C.bit_DeletedFlag,0)=0))) end As vch_Remarks ,(case isnull(A.bit_ReceiveStatus,0) when 1 then '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
End
End

end


This is the case i am using within a procedure while executing my query i am getting following error please help me to solve them.

case vch_Remarks when Null then (select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0) else (select vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0))) end As vch_Remarks

errors are Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'case'. Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'else'. Msg 156, Level 15, State 1, Line 5 Incorrect syntax near the keyword 'Select'. Msg 102, Level 15, State 1, Line 6 Incorrect syntax near ')'.



my complete procedure is


CREATE PROCEDURE [dbo].[USP_ViewRejectedReport]
(
	
	@Pvch_AdvertisementNo varchar(200),
	@Pvch_Post_Code varchar(100),
	@Pint_DistrictId int,
	@PintType int	
)

as
begin
            If (@PintType = 1)
              Begin
                If (@Pint_DistrictId = 0)
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
                End
                Else
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
                End 
              End
            
            Else If (@PintType = 2)
            Begin
                If (@Pint_DistrictId = 0) 
                Begin
                 
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
                End
                Else
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
                End
            End
            Else If (@PintType = 3)
            Begin                 
                If (@Pint_DistrictId = 0)
                Begin 
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
                End
                Else
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
                End
                
            End 
            Else If (@PintType = 4) 
            Begin
                If (@Pint_DistrictId = 0)
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
                End
                Else
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
                End
            End 
            Else
              Begin
                If (@Pint_DistrictId = 0)
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
                End
                Else
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
                End 
            End
         
 end

解决方案

Try this, I think last parenthesis is missing
sq

(case vch_Remarks when Null then 
(select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0) 
else 
(select vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0)) 
end ) As vch_Remarks


CREATE PROCEDURE [dbo].[USP_ViewRejectedReport]
(

    @Pvch_AdvertisementNo varchar(200),
    @Pvch_Post_Code varchar(100),
    @Pint_DistrictId int,
    @PintType int
)

as
begin
            If (@PintType = 1)
              Begin
                If (@Pint_DistrictId = 0)
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
                End
                Else
                Begin
                    select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,case vch_Remarks when Null then (select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0)else (select  vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(C.bit_DeletedFlag,0)=0))) end As vch_Remarks ,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
                End
              End

            Else If (@PintType = 2)
            Begin
                If (@Pint_DistrictId = 0)
                Begin

                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
                End
                Else
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,case vch_Remarks when Null then (select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0)else (select  vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(C.bit_DeletedFlag,0)=0))) end As vch_Remarks ,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
                End
            End
            Else If (@PintType = 3)
            Begin
                If (@Pint_DistrictId = 0)
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
                End
                Else
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,case vch_Remarks when Null then (select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0)else (select  vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(C.bit_DeletedFlag,0)=0))) end As vch_Remarks ,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
                End

            End
            Else If (@PintType = 4)
            Begin
                If (@Pint_DistrictId = 0)
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
                End
                Else
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,case vch_Remarks when Null then (select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0)else (select  vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(C.bit_DeletedFlag,0)=0))) end As vch_Remarks ,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
                End
            End
            Else
              Begin
                If (@Pint_DistrictId = 0)
                Begin
                   select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,   A.vch_CorMobileNo,   ( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )vch_Remarks,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo= @Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code order by A.vch_UniqueRefNo
                End
                Else
                Begin
                    select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,case vch_Remarks when Null then (select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0)else (select  vch_remarks From M_Remark_Detail where int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(C.bit_DeletedFlag,0)=0))) end As vch_Remarks ,(case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo=@Pvch_AdvertisementNo and A.vch_Post_Code=@Pvch_Post_Code and A.int_examDistrictId=@Pint_DistrictId order by A.vch_UniqueRefNo
                End
            End

 end


这篇关于请帮我解决错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆