试试 not between
- ------------------------------------
- -- Author:Flystone
- -- Version:V1.001
- -- Date:2008-08-02 23:26:50
- ------------------------------------
- -- Test Data: @t
- declare @t table(id int)
- insert into @t
- select top 20 id from sysobjects
- --Start
- Select * from @t
- --Result:
- /*
- id
- -----------
- 1
- 2
- 3
- 4
- 6
- 8
- 9
- 10
- 11
- 12
- 14
- 19
- 20
- 21
- 22
- 23
- 24
- 95
- 96
- 979330
- (所影响的行数为 20 行)
- */
- select *
- from @t
- where id not between 5 and 20
- --Result:
- /*
- id
- -----------
- 1
- 2
- 3
- 4
- 21
- 22
- 23
- 24
- 95
- 96
- 979330
- (所影响的行数为 11 行)
- */
- --End