Q&A about the site for science fiction and fantasy enthusiasts
DECLARE @SearchText VARCHAR(100) = ##SearchText:string## DECLARE @OnlyBeginning BIT = ##OnlyBeginning:int## DECLARE @IncludeDeleted BIT = ##IncludeDeleted:int## DECLARE @After DATETIME = ##After:string## SELECT TOP 100 Id AS [Post Link], CreationDate, Body, IIF(DeletionDate IS NOT NULL, 'Yes', 'No') AS Deleted FROM Posts WHERE PostTypeId = 2 AND (@IncludeDeleted = 1 OR DeletionDate IS NULL) AND ( (@OnlyBeginning = 1 AND Body LIKE @SearchText + '%') OR (Body LIKE '%' + @SearchText + '%') ) AND (CreationDate > @After) ORDER BY CreationDate DESC