Last active
July 21, 2021 20:18
-
-
Save manoj-choudhari-git/6d36552c9c62cffe3e19cb9f1f9c9760 to your computer and use it in GitHub Desktop.
.NET EF Core - A scalar valued function for a demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
CREATE FUNCTION [dbo].[GetStudentsCountWithSameLastName] | |
( | |
@lastName nvarchar(50) | |
) | |
RETURNS INT | |
AS | |
BEGIN | |
-- Variable | |
DECLARE @numberOfStudents int; | |
-- Populate number of records variable | |
SELECT @numberOfStudents = COUNT(*) | |
FROM Students | |
WHERE LastName = @lastName; | |
-- Return the number of records | |
RETURN @numberOfStudents; | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment