SQL存储过程问题
我对以下存储过程有问题SQL存储过程问题,sql,sql-server,stored-procedures,Sql,Sql Server,Stored Procedures,我对以下存储过程有问题 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
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
“选择TOP@count*”出现问题,为什么我不能“选择TOP@variablemount”记录?
注意:另外,SQL Server 2005+用于参数化的TOP的可能重复项
...
SELECT TOP (@count) *
...