Complete the code to start creating a stored procedure named 'GetAllUsers'.
CREATE [1] GetAllUsers AS BEGIN SELECT * FROM Users; END;The keyword PROCEDURE is used to create a stored procedure in SQL.
Complete the code to define a parameter named 'UserId' of type INT for the procedure.
CREATE PROCEDURE GetUserById ([1] INT) AS BEGIN SELECT * FROM Users WHERE Id = @UserId; END;In many SQL dialects, procedure parameters start with '@' to denote variables.
Fix the error in the procedure declaration by choosing the correct keyword to end the procedure.
CREATE PROCEDURE DeleteUser (@UserId INT) AS BEGIN DELETE FROM Users WHERE Id = @UserId; [1] END;The END keyword is used to close the BEGIN block in SQL procedures.
Fill both blanks to create a procedure that updates a user's email by their ID.
CREATE PROCEDURE UpdateEmail ([1] INT, [2] VARCHAR(100)) AS BEGIN UPDATE Users SET Email = @Email WHERE Id = @UserId; END;
Parameters must be prefixed with '@' and match the names used inside the procedure.
Fill all three blanks to create a procedure that inserts a new user with name and age.
CREATE PROCEDURE AddUser ([1] VARCHAR(50), [2] INT) AS BEGIN INSERT INTO Users (Name, Age) VALUES ([3], @Age); END;
Parameters must be prefixed with '@' and used consistently inside the procedure.