Hi All,
I have a requirement, i want to replace string with id value from another table value.
Another table id's:
4698,50470,50490,4698,5047
ID NAME
4698 ABC
5047 DEF
5049 GHI
Source String : (subitemid_4698&& (subitemid_5047>=0 ||subitemid_GHI>=0)) || (!subitemid_ABC && subitemid_DEF==0 && subitemid_GHI==0)
Ouput String: (subitemid_ABC&& (subitemid_DEF>=0 ||subitemid_5049>=0)) || (!subitemid_4698 && subitemid_5047==0 && subitemid_5049==0)
/Below is the Query i tried/
------------------------------------------------------------------------------------------------------------------
DECLARE @strNumbers VARCHAR(100) = '(productid_4698&& (productid_5047>=0 ||productid_5049>=0)) || (!productid_4698 && productid_5047==0 && productid_5049==0)'
DECLARE @Inputparms VARCHAR(100)
DECLARE @POS SMALLINT = 0
SET @POS = PATINDEX('%[^_0-9]%', ISNULL(@strNumbers,0)) --Find first character
WHILE (@POS > 0)
BEGIN
SET @strNumbers = STUFF(@strNumbers, @POS , 1, '')
SET @POS = PATINDEX('%[^_0-9]%', @strNumbers)
END
SET @Inputparms= (SELECT REPLACE(RIGHT(@strNumbers, LEN(@strNumbers) - 1),'_',','))
select @Inputparms
----------------------------------------------------------------------------------------------------------
Thanks in Advance...