-1

我知道我们可以Select * from abc where xyz=@xyz使用SqlCommand.Parameters.AddWithValue("@xyz",xyz)C# 代码添加查询参数。但是是否可以更改顶行参数以进行类似的Select TOP @rows * from abc where xyz=@xyz查询SqlCommand.Parameters.AddWithValue("@rows",32)

因为每当我尝试它时,它都会向我显示这个异常:Incorrect syntax near '@rows'.

4

1 回答 1

3

您可以明确地将整数传递到顶部子句。你应该能够做这样的事情。

select top (@Rows) *
from dbo.MyTable
order by something
于 2013-08-02T18:46:58.397 回答