if OBJECT_ID('myTable') IS NOT NULL DROP TABLE myTable go
create table myTable ( field1 int ,field2 char(4) ) go Insert into myTable(field1,field2) Values(001,'aaaa') Insert into myTable(field1,field2) Values(101,'bbbb') Insert into myTable(field1,field2) Values(201,'dfdf') Insert into myTable(field1,field2) Values(301,'sfsf') Insert into myTable(field1,field2) Values(401,'dgfg') Insert into myTable(field1,field2) Values(501,'hjjh') Insert into myTable(field1,field2) Values(601,'45rf') Insert into myTable(field1,field2) Values(701,'fhhh') Insert into myTable(field1,field2) Values(801,'ghhn') Insert into myTable(field1,field2) Values(901,'gfhh')
go
declare @n int
set @n=3
SELECT IDENTITY (int, 1, 1) As Rank ,t.* INTO #tmp FROM dbo.myTable t
select * from #tmp where rank % @n = 0
drop table #tmp |