3
我有以下存儲過程與發生SQL存儲過程的問題
CREATE PROCEDURE LockRoots
-- Add the parameters for the stored procedure here
@lock uniqueidentifier,
@count int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
UPDATE R
SET R.[Lock] = @lock
FROM
(
SELECT TOP @count *
FROM [Root] as R
--LEFT JOIN [Container] as C ON R.ID = C.RootID
WHERE [Lock] IS NULL
--ORDER BY NEWID()
);
END
GO
問題的問題「SELECT TOP @count *」,我爲什麼不能「選擇最前@VariableAmount」記錄?
可能重複[?如何從其中n的值在運行時通過桌面n行] (http://stackoverflow.com/questions/2260767/how-to-get-top-n-rows-from-a-table-where-value-of-n-is-passed-at-run-time) – 2011-06-15 06:47:34