试试 not between
- ------------------------------------
- --Author:Flystone
- --Version:V1.001
- --Date:2008-08-0223:26:50
- ------------------------------------
- --TestData:@t
- declare@ttable(idint)
- insertinto@t
- selecttop20idfromsysobjects
- --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
- whereidnotbetween5and20
- --Result:
- /*
- id
- -----------
- 1
- 2
- 3
- 4
- 21
- 22
- 23
- 24
- 95
- 96
- 979330
- (所影响的行数为11行)
- */
- --End