SQL Server Stored Procedure: Add Condition 'yyzx like t1.aaa' to SP_Get_EOL
To add a condition "yyzx like t1.aaa" to the stored procedure, you can modify the existing code as follows:
\
CREATE PROCEDURE [dbo].SP_Get_EOL\
@yyzx NVARCHAR(20), --营运中心\
@pinhao NVARCHAR(128) --品号\
AS \
EXEC SP_PLM_COLPIVOT\
@TABLENAME = N'select t1.*,t2.FIELD_NAME,t2.FIELD_VALUE from Aras_PLM.innovator.LABEL_AND_EOL t1\
left join Aras_PLM.innovator.EOL_INFO t2 on t2.SOURCE_ID = t1.id \
where 1 = 1\
and t1.eol_state in(''released'', ''in change'')\
and t1.old_or_new_signs = ''2''\
and yyzx like ''%'' + t1.aaa + ''%''', -- Add the condition here\
@GROUPCOLUMN = N'KEYED_NAME',\
@JSTYPE = N'MAX',\
@ROW2COLUMN = N'FIELD_NAME',\
@ROW2COLUMNVALUE = N'FIELD_VALUE',\
@SQL_WHERE = N'where 1 = 1' ;\
```\
\
The condition `yyzx like ''%'' + t1.aaa + ''%''` will check if the `yyzx` parameter is present in the `t1.aaa` column. The `LIKE` operator with `%` wildcard characters is used to match any characters before and after the `yyzx` value.
原文地址: https://www.cveoy.top/t/topic/p3lN 著作权归作者所有。请勿转载和采集!