Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Maximum length @paramter in Procedure

Author  Topic 

dophuong_cs
Starting Member

15 Posts

Posted - 2014-05-14 : 02:40:04
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)
AS
BEGIN
declare @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_Id
where c.Ecn_Active=''A''
and c.Ecn_Final_Status<>''C'''+ @c_where;--
--exec (@sql)
EXECUTE sp_executesql @sql;
print @sql

END


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 1
The 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

stepson
Aged Yak Warrior

545 Posts

Posted - 2014-05-14 : 02:58:40
maybe this will help:
http://databasetimes.blogspot.ro/2009/05/is-too-longmaximum-length-is-128.html
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=11588


sabinWeb MCP
Go to Top of Page

dophuong_cs
Starting Member

15 Posts

Posted - 2014-05-14 : 03:31:27
Hi,thank you very much for your answer.
I try follow your advice, however unsuccessful.
Please continue support me.

Phuong
Go to Top of Page

stepson
Aged Yak Warrior

545 Posts

Posted - 2014-05-14 : 03:51:56
[code]
declare @vcSTR as varchar(8000)
SET @vcSTR ='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)%'''

EXEC Pro_Pur_View_Upload_Data_Send_Sup @vcSTR,'v428187'
[/code]


sabinWeb MCP
Go to Top of Page
   

- Advertisement -