Hello,
My MasterData table looks like:-
DECLARE @DATATABLE TABLE ( CountryID INT, IID VARCHAR(10), PROD VARCHAR (50), Description VARCHAR (250), CLAS INT ) INSERT @DATATABLE SELECT 12,'IM','S350A','LCKNG NAT',04 UNION ALL SELECT 45,'RD','16M120','FLAT WASHER',04 UNION ALL SELECT 12,'IM','A14751','CNCTR2.5MM',01 UNION ALL SELECT 12,'IM','X15129','OIL LEVEL',01 UNION ALL SELECT 69,'XY','5VB554','SOLID',14 UNION ALL SELECT 71,'NS','1Q5128','EVELLI',14 UNION ALL SELECT 71,'YT','PM2001','MINI31',01 SELECT * FROM @DATATABLE
And The Driver table feilds looks like:-
DECLARE @DRIVERTABLE TABLE ( SP_Name VARCHAR(50), PROD VARCHAR(50), CountryID INT, CLAS VARCHAR(30), SelectionBIT INT ) INSERT @DRIVERTABLE SELECT 'usp_testprod','','12','04,01','1' union all SELECT 'usp_testprod','','12','04' ,'0' union all SELECT 'usp_testprod','','12','09' ,'0' union all SELECT 'usp_testprod','','31','04' ,'0' union all SELECT 'usp_testcust','A14751','65','','1' union all SELECT 'usp_testcust','PM2001','39','','0'
I am trying to develop stored procedure which return data from Master Data table using parameter from driver table.
when SP Name match and SelectionBIT = 1 then it will use feilds from driver table which are not null or not blank to pass as input parameter to get output.
Expected Output of SP usp_testprod is:
12 IM S350A LCKNG NAT 4 12 IM A14751 CNCTR2.5MM 1 12 IM X15129 OIL LEVEL 1
as country id = 12 and iclas in (1,4)
Kindly help if it seems realistic, as SelectionBIT is only available in driver table but not in data table.