3
我正在創建一個如下所示的過程。當沒有「TOP @Count」時它可以正常工作,或者當我將「TOP 100」設置爲具體值時它工作正常。不能用戶「選擇TOP @Count ...」
那麼,爲什麼我不能通過那裏的價值?我怎麼走動它?
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE MyProcedure
@Count int = 100
AS
BEGIN
SELECT TOP @Count
t1.id AS ID,
t1.name AS Name,
t2.type AS TYPE
FROM sampleTable1 as t1 with (noloack),
sampleTable2 as t2 with (noloack)
WHERE (t1.t2Id = t2.Id)
ORDER BY t1.name asc
END
GO