I am having a problem with the following stored procedure
CREATE PROCEDURE LockRoots
@lock uniqueidentifier,
@count int
AS
BEGIN
SET NOCOUNT ON;
UPDATE R
SET R.[Lock] = @lock
FROM
(
SELECT TOP @count *
FROM [Root] as R
WHERE [Lock] IS NULL
);
END
GO
The problem arises with "SELECT TOP @count *", why can't I select the "top @VariableAmount" entries?
source
share