Code only answers


Please login or register to vote for this query.

(click on this box to dismiss)

Ask Different

Q&A for power users of Apple hardware and software

DECLARE @MaxTextLenBeforeCode AS INT = ##MaxTextLenBeforeCode:int?0##;
DECLARE @MaxTextLenAfterCode AS INT = ##MaxTextLenAfterCode:int?0##;

  Id AS [Post Link],
  CHARINDEX('<pre><code>', Body) - 1 AS TextLenBeforeCode,
  LEFT(Body, CHARINDEX('<pre><code>', Body) - 1) AS TextBeforeCode,
  LEN(Body) - CHARINDEX('</code></pre>', Body) - LEN('</code></pre>') AS TextLenAfterCode,
  RIGHT(Body, LEN(Body) - CHARINDEX('</code></pre>', Body) - LEN('</code></pre>')) AS TextAfterCode,
FROM Posts
WHERE PostTypeId = 2  -- answers
  AND CHARINDEX('<pre><code>', Body) > 0
  AND CHARINDEX('<pre><code>', Body) - 1 <= @MaxTextLenBeforeCode
  AND CHARINDEX('</code></pre>', Body) + LEN('</code></pre>') >= LEN(Body) - @MaxTextLenAfterCode
  AND ClosedDate IS NULL
ORDER BY Score DESC, CreationDate

Enter Parameters

Switch to meta site
loading Hold tight while we fetch your results