I have this procedure :
CREATE PROC dbo.##HTMLtoMARKDOWN @text nvarchar(500),
@returnText nvarchar(500) output
AS
BEGIN
DECLARE @counter tinyint
SET @counter=1
WHILE CHARINDEX('**', @text, 1) > 0
BEGIN
SELECT @text = STUFF(@text,
CHARINDEX('**', @text, 1),
2,
IIF(@counter%2=0,'<br><b>','</b>')),
@counter = @counter + 1
END
SET @returnText = @text
END
GO
Which can be run like this:
DECLARE @returnText nvarchar(500)
EXEC dbo.##HTMLtoMARKDOWN '**a** **b** **c**', @returnText output
I'm using this kind of query:
Select, IIF(IsUniversal=0,'TRUE','FALSE') as [Is Universal?],
MarkdownMini as [Off Topic Reason]
From CloseAsOffTopicReasonTypes
group by IsUniversal, MarkdownMini
Ifdbo.##HTMLtoMARKDOWNwas declared as a function (CREATE FUNCTION dbo.HTMLtoMARKDOWN @text nvarchar(500))), I could have written this:
Select, IIF(IsUniversal=0,'TRUE','FALSE') as [Is Universal?],
dbo.HTMLtoMARKDOWN(MarkdownMini) as [Off Topic Reason]
From CloseAsOffTopicReasonTypes
group by IsUniversal, MarkdownMini
I'm not allowed to use functions, so how I can do that kind of thing with a temporary procedure?
This one works by applying the stored procedure to the distinct reasons rather than processing the whole set.