Luis Cazares (10/20/2016)
That's a weird requirement. What's the story behind this?Here's a shorter alternative which I expect that might be a bit faster (not much).
WITH numbers AS
(
SELECT ROW_NUMBER() OVER ( ORDER BY id ) AS num
FROM syscolumns
)
SELECT *
FROM numbers
WHERE numbers.num % 10 NOT IN (4, 8) ;
Probably would be quicker - integer mathematics got to be quicker than converting to string and slicing... surely...
...but the bigger question is, why didn't I think of that? 😀
Thomas Rushton
blog: https://thelonedba.wordpress.com