SELECT TOP 10 *
FROM tablename
WHERE (id NOT IN
          (SELECT TOP 10 id
         FROM tablename))
这样子可以吗!其中id为表中的任何一个字段名称

解决方案 »

  1.   

    //我得想法是添加一个列,该列为自增列
    //然后筛选该列
    DataSet ds = getdataset();
    DataColumn dc = new DataColumn("testOrderID",typeof(long));
    dc.AutoIncrement = true;
    dc.AutoIncrementSeed =1;
    dc.AutoIncrementStep = 1;
    ds.Tables[0].Columns.Add(dc);
    DataView dv = new DataView(dt,"testOrderID >10 and testOrderID <=20","testOrderID",System.Data.DataViewRowState.CurrentRows);
      

  2.   

    veaven(风林火山) 的方法挺好
    怎么会有记录被删就出错啦
      

  3.   

    使用分页,每页十条记录,pageindex赋值为1,直接显示第二页!
      

  4.   

    SELECT TOP PageSize * FROM TableName WHERE ID not in (SELECT TOP StartIndex-1 ID FROM TableName)StartIndex是从第几条开始,PageSize是每页多少条。
    查某条记录到某条记录之间,把上面形式改改就行了。
    上面的前提是有一个递增的主键。
      

  5.   

    使用临时表来实现:两条语句之间用分号分隔
    select * from TableName into #table where id not in (select top 10 id from tablename); select top 10 from #table
      

  6.   

    我给你一段分页显示的存储过程.
    是高效掌握Asp.net这本书里的.wrox出的.
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_GetEmployeesByPage]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
    drop procedure [dbo].[sp_GetEmployeesByPage]
    GOSET QUOTED_IDENTIFIER OFF 
    GO
    SET ANSI_NULLS OFF 
    GOCREATE PROCEDURE sp_GetEmployeesByPage
    @PageNumber int,
    @PageSize int
    AS-- create a temporary table with the columns we are interested in
    CREATE TABLE #TempEmployees
    (
    ID  int IDENTITY PRIMARY KEY,
    EmployeeID int,
    LastName nvarchar(20),
    FirstName nvarchar(10),
    Title nvarchar(30),
    TitleOfCourtesy nvarchar(25),
    Address nvarchar(60),
    City nvarchar(15),
    Region nvarchar(15),
    Country nvarchar(15),
    Notes ntext
    )-- fill the temp table with all the employees
    INSERT INTO #TempEmployees
    (
    EmployeeID,
    LastName,
    FirstName,
    Title,
    TitleOfCourtesy,
    Address,
    City,
    Region,
    Country,
    Notes
    )
    SELECT 
    EmployeeID,
    LastName,
    FirstName,
    Title,
    TitleOfCourtesy,
    Address,
    City,
    Region,
    Country,
    Notes
    FROM 
      Employees ORDER BY EmployeeID ASC-- declare two variables to calculate the range of records to extract for the specified page
    DECLARE @FromID int
    DECLARE @ToID int
    -- calculate the first and last ID of the range of records we need
    SET @FromID = ((@PageNumber - 1) * @PageSize) + 1
    SET @ToID = @PageNumber * @PageSize-- select the page of records
    SELECT * FROM #TempEmployees WHERE ID >= @FromID AND ID <= @ToID
    GO
    SET QUOTED_IDENTIFIER OFF 
    GO
    SET ANSI_NULLS ON 
    GO
      

  7.   

    假设你的是myTable;
    newTable = new DataTable();
    for (int i=0;i<myTable.Rows.Count;i++)
    {
      if (i>10)&&(i<19)
       {
        thisrow=new DataRow();
        thisrow[0]=myTable.Rows[i][0] ;
        thisrow[1]=myTable.Rows[i][1] ;
        .....      
        newTable.Rows.Add()
           }
     }对不起,我大概写了一个,其中有些地方不对,你修改修改吧。