السلام عليكــم ورحمـة الله وبركاتــة ،،
عندي اجراء مخزن في القاعدة و اريد اضافة شرط كمايلي
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go
-- =============================================
-- Author: <zekiri,abdelali>
-- Create date: <09-03-2009>
-- =============================================
ALTER PROCEDURE [dbo].[GetListInj]
@IDST varchar(400),
@IDOP varchar(400),
@LEVEL varchar(20) ,
@LANG varchar(400)
AS BEGIN SELECT sub.StName, soa.idop,soa.opname, soa.CountryCode,opmkg.opLevel,
count(stop.cpycode) AS 'countCpy'
FROM dbt..op stop (nolock),
dbt..opassignment soa (nolock),
dbt..subco sub (nolock),
cop..OOPMKG opmkg (nolock)
WHERE soa.idop = stop.idop and soa.idop = opmkg.OpMkgCode and soa.idst = sub.idst and (stop.CPB_ResultCode='OKCPB') and (stop.CPB_URD BETWEEN '2009-02-03' and '2009-03-03')
[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
Group BY sub.StName, soa.idop,soa.opname ,soa.CountryCode,opmkg.opLevel
END
الشرط يكون كمايلي
اذاكان المتغير
IDST = -1
لا تقوم باضافة شرط الفلترة and soa.idst in (@IDST)
و ايضا بانسية ل IDOP and stop.idop in (@IDOP)هذا ما قمت به لكن لا يعمل
and ((@IDST = -1 ) or (soa.idst in (@IDST))) and ((@IDOP = -1 ) or (stop.idop in (@IDOP) ) ) and ((@LEVEL = -1) or (opmkg.opLevel in (@LEVEL)) ) and ((@LANG = -1 ) or (soa.CountryCode in (@LANG) ) )
شكرا بكم