Hi Pituach,
Below is the Table structure
Tbl_Product
Create table Tbl_Product
(
Product varchar(50) NULL,
Code Varchar (50) NULL
)
Insert into Tbl_Product values('PEN','A')
Insert into Tbl_Product values('BOOK','B')
Insert into Tbl_Product values('PENCIL','C')
Insert into Tbl_Product values('TV','D')
Insert into Tbl_Product values('COMPUTER','E')
Insert into Tbl_Product values('SHOES','F')
Insert into Tbl_Product values('SHIRT','G')
Tab_KeyValue
Create table tbl_KeyValue
(
value char(3) NULL,
keys int NULL
)
Insert into tbl_Keyvalue values('A',1)
Insert into tbl_Keyvalue values('B',2)
Insert into tbl_Keyvalue values('C',3)
Insert into tbl_Keyvalue values('D',4)
Insert into tbl_Keyvalue values('E',5)
Insert into tbl_Keyvalue values('F',6)
Insert into tbl_Keyvalue values('G',7)
Main Procedure:
CREATE PROCEDURE DBO.SP_WRAPPD
(PRODUCT1 VARCHAR(1000))
AS
BEGIN
DECLARE @COMMA VARCHAR(2)
SET @COMMA =','
SELECT CODE FROM TBL_PRODUCT WHERE CHARINDEX(PRODUCT,@PRODUCT) >0
END
Second procedure:
Create Procure sp_findIndexes(@value varchar(10))
as
begin
Declare @keys int
set @Keys =(select A.keys from tbl_keyvalue A where
A.value=@value)
Declare @Evenodd varchar(10)
Declare @result int
Exec @result =sp_EvenOdds @keys
if @result=1
set @EvenOdd ='Even'
else
set @EvenOdd='Odd'
insert