TOP n [PERCENT]n 指定返回的行数。如果未指定 PERCENT,n 就是返回的行数。如果指定了 PERCENT,n 就是返回的结果集行的百分比,如下所示:TOP 120 /*Return the top 120 rows of the result set. */
TOP 15 PERCENT /* Return the top 15% of the result set. */.

解决方案 »

  1.   

    好像 那 Top n 的 N 不能是参数?数据库我学得不好。
      

  2.   

    top后面的数字只能用变量,不能用cmd参数传递
      

  3.   

    string sql = "SELECT TOP " + number + " *
                               FROM test
                               WHERE (testCourse = @courseId) and (pub = 1) 
                                 AND (typeofproblem = @type)";
      

  4.   

    string sql = "SELECT TOP " + number + " *
                               FROM test
                               WHERE testCourse = @courseId and pub = 1 
                                 AND typeofproblem = @type";
    也没有必要要括号。只能用变量值
      

  5.   

    "top"後面不能帶變量,必須是常數。