CREATE PROCEDURE dbo.GetCountByLastName
(@LastName NVARCHAR(50),
@LastNameCount INT OUTPUT )
AS
SELECT @LastNameCount = COUNT(*) FROM Person.Contact
WHERE LastName = @LastName
Now we call this procedure as
DECLARE @TheCount INT
EXEC dbo.GetCountByLastName
@LastName = 'Senthil',
@LastNameCount = @TheCount OUTPUT
SELECT TheCount = @TheCount
No comments:
Post a Comment