Return the Closest Prime Number

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gardening and Landscaping Meta

Q&A about the site for gardeners and landscapers

use master
DECLARE @ INT=21;

WITH C(r) as(SELECT abs(number)+2FROM spt_values)SELECT
top 1*FROM c d
WHERE 0not in(SELECT d.r%r FROM c
WHERE d.r>r)ORDER BY abs(r-@),r

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results