Dear all,I have face problem with @parameter in sql procedure.ALTER PROCEDURE [dbo].[Pro_Pur_View_Upload_Data_Send_Sup]@c_where varchar(8000) =NULL,@User varchar(max)ASBEGINdeclare @sql varchar(max)set @sql ='';set @sql = @sql + 'select convert(varchar,epc.ECN_Send_Date_Id), esd.ECN_No, esd.Part_No, esd.Part_Name, esd.Cd_Block AS Sup_Code, epc.Draw_No, epc.His_No, epc.Request_Date, epc.User_Request, (select a.Rv_Meaning from ECN_CG_REF_CODE a where a.Rv_Domain =''PUR_SEND'' and a.Rv_Low_Value =epc.Request_Status ) as Request_Status, epc.User_Entry, CONVERT(varchar, epc.Date_Entry,112) as Date_Entry, epc.User_Update, CONVERT(varchar, epc.Date_Update,112) as Date_Update from (ECN_PART_COVER esd join ECN_COVER c on esd.Ecn_No=c.Ecn_No) left outer join ECN_SEND_DATE epc on epc.Ecn_Part_Cover_Id = esd.Ecn_Part_Cover_Idwhere c.Ecn_Active=''A'' and c.Ecn_Final_Status<>''C'''+ @c_where;----exec (@sql)EXECUTE sp_executesql @sql;print @sqlEND
Now, i run procedure as below: EXEC Pro_Pur_View_Upload_Data_Send_Sup "and 1 = 1 and esd.Ecn_No like '%JJJ91770%' and esd.Part_No like '%RC3-2436-000%' and esd.Cd_Block like '%M596%' and epc.Request_Date like '%20140514%' and epc.Request_Status like '%1%' and epc.Draw_No like '%005%' and epc.His_No like '%002%' and esd.Part_Name like '%MP tray (OOV3-Texture)%'",v428187
And errors occurs Msg 103, Level 15, State 4, Line 1The identifier that starts with 'and 1 = 1 and esd.Ecn_No like '%JJJ91770%' and esd.Part_No like '%RC3-2436-000%' and esd.Cd_Block like '%M596%' and epc.Request_' is too long. Maximum length is 128.
How to fix problem with procedure?please help me.Phuong