I have this script that executes, but I need it to take a user input instead of the setting the variable for @lastName.
CREATE FUNCTION displayCount() RETURNS INT
AS
BEGIN
DECLARE @number INT, @lastName VARCHAR(40);
SET @lastName = 'Ferrier';
SELECT @number = COUNT(*) FROM Person.Person
WHERE LastName = @lastName;
RETURN @number;
END
GO
SELECT dbo.displayCount() AS howMany
I tried to mess with what I thought would work, but doesn't. I am getting and error
'Procedure or function dbo.diplayCount has too many arguments'
I'm sure it's something simple and with me being SO NEW, I can't see it. Thanks for the help!!
CREATE FUNCTION displayCount(@lastName VARCHAR(40)) RETURNS INT
AS
BEGIN
DECLARE @number INT;
SELECT @number = COUNT(*) FROM Person.Person
WHERE LastName = @lastName;
RETURN @number;
END
GO
SELECT dbo.displayCount('Ferrier') as howMany
SQL Server Management Studio?