I am creating a procedure something like below. it works fine when there is no "TOP @Count", or it works fine when i put a concrete vaule "TOP 100" .
So why i cannot pass the value there??? how can i walk around it???
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