Create a stored procedure usp_StudentLogin that tests if a student exists. After
ID: 3853762 • Letter: C
Question
Create a stored procedure usp_StudentLogin that tests if a student exists. After the stored procedure name, you list all the parameters for the procedure. Parameters are values the user must enter when they execute the procedure. In this case, you will just need the StudentKey. After the parameters, the 'AS' keyword signals the start of the content of the procedure, The first thing we are going to do is see if a record exists for the user in the student table. The BEGIN and END keywords mark the beginning and ending of the true block. If it does, it will return the student's last name. If it doesn't exist, we won't do anything. The application can test to see whether the name is returned. ANSWER:Explanation / Answer
Create PROCEDURE usp_StudentLogin(
@SearchKey INT
)
AS
BEGIN
SELECT LastName FROM Student WHERE StudentKey=@SearchKey
END
In the above,
The name of stored Procedure is usp_StudentLogin
The name of the table is Student
The column name in the Student table is StudentKey, of type int
The parameter name is SearchKey which contains the value we are looking for in the StudentKey column of Student table.
The stored procedure will return LastName for matching record if it exists and nothing when it does not exist.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.