Please also check:
CREATE FUNCTION [dbo].Func(@string varchar(40)) returns varchar(max)
AS
BEGIN
DECLARE @result varchar(max)
SET @result=@string
DECLARE @num int
SET @num=1
WHILE @num>0
BEGIN
SET @result=REPLACE(@result,SUBSTRING(@result,CHARINDEX('<',@result)
,CHARINDEX('>',@result)-CHARINDEX('<',@result)+1),'')
SET @num=CHARINDEX('<',@result)
END
RETURN @result
END
SELECT *,dbo.Func(Qst) Qst,dbo.Func(Ans) Ans
FROM yourtable
DROP function dbo.Func
Output:
If you have any question, please feel free to let me know.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.