Q&A for professional and amateur woodworkers
--parameter should be "Cov" if you are looking for \Cov --notice that both \DeclareMathOperator{\Cov}{Cov} and --We do not want the macro to be followed by alphanumerical character --For example we want to match: \C but not \Cov, \norm but not \normalsize, \Q but not \quad --thanks to rene for suggestion to use regex: https://chat.meta.stackexchange.com/transcript/1223/2019/2/1 SELECT TOP(##num?50##) a.Id AS [Post Link], url = 'site://posts/' + CAST(a.Id AS varchar)+'/revisions', a.OwnerUserId AS [User Link], a.CreationDate, a.LastActivityDate, a.Score, a.Body FROM Posts a JOIN Posts q ON a.ParentId=q.Id WHERE (a.Body LIKE '%[^\]\##text?\C##[^a-zA-Z]%') AND NOT ((a.Body LIKE '%\newcommand{\##text##}%') OR (a.Body LIKE '%\newcommand\##text##%') OR (a.Body LIKE '%\DeclareMathOperator{\##text##}%') OR (a.Body LIKE '%\DeclareMathOperator\##text##%') OR (a.Body LIKE '%\def{\##text##}%') OR (a.Body LIKE '%\def\##text##%') OR (a.Body LIKE '%\newcommand{##text##}%') OR (a.Body LIKE '%\DeclareMathOperator{##text##}%')) --notice that both \DeclareMathOperator{Aut}{Aut} and \DeclareMathOperator{\Aut}{Aut} give the same result in MathJax AND ((q.Body LIKE '%\newcommand{\##text##}%') OR (q.Body LIKE '%\newcommand\##text##%') OR (q.Body LIKE '%\DeclareMathOperator{\##text##}%') OR (q.Body LIKE '%\DeclareMathOperator\##text##%') OR (q.Body LIKE '%\def{\##text##}%') OR (q.Body LIKE '%\def\##text##%') OR (q.Body LIKE '%\newcommand{##text##}%') OR (q.Body LIKE '%\DeclareMathOperator{##text##}%')) ORDER BY a.CreationDate DESC