The following script creates a single-column clustered table containing the integers from 1 to 1,000 inclusive.
IF OBJECT_ID(N'tempdb..#Test', N'U') IS NOT NULL
BEGIN
DROP TABLE #Test
END;
GO
CREATE TABLE #Test
(
id integer PRIMARY KEY CLUSTERED
);
INSERT #Test
(id)
SELECT
V.number
FROM master.dbo.spt_values AS V
WHERE
V.[type] = N'P'
AND V.number BETWEEN 1 AND 1000;
Let’s say we are given the following task:
Find the rows with values from 100 to 170, excluding any values that divide exactly by 10.