如下列sql:

select top XX * from tableName

在参数化时,可以写成:

select top @recordCount * from tableName

但这样写在执行时会提示在"@recordCount"附近有语法错误.

正确的写法是:

select top (@recordCount) * from tableName

就是将参数加上括号!