2016-04-29 49 views

回答

16

在SQL Server中,除數字常量之外的任何top表達式都需要括在括號內。

SELECT TOP (@MaxLimit) FROM ... 
+2

在2005年和更大的僅支持。 (顯示我的年齡) – mxmissile

1

這也適用於較新版本的小巧玲瓏:

var sql = "Select Top {=MaxLimit} from Table WHere data [email protected]";