0
0
SQLquery~10 mins

CREATE PROCEDURE syntax in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start creating a stored procedure named 'GetAllUsers'.

SQL
CREATE [1] GetAllUsers AS BEGIN SELECT * FROM Users; END;
Drag options to blanks, or click blank then click option'
APROCEDURE
BVIEW
CTRIGGER
DFUNCTION
Attempts:
3 left
💡 Hint
Common Mistakes
Using FUNCTION instead of PROCEDURE
Using VIEW or TRIGGER keywords incorrectly
2fill in blank
medium

Complete the code to define a parameter named 'UserId' of type INT for the procedure.

SQL
CREATE PROCEDURE GetUserById ([1] INT) AS BEGIN SELECT * FROM Users WHERE Id = @UserId; END;
Drag options to blanks, or click blank then click option'
A#UserId
BUserId
C@UserId
D$UserId
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the '@' symbol before parameter names
Using '#' or '$' which are not standard for parameters
3fill in blank
hard

Fix the error in the procedure declaration by choosing the correct keyword to end the procedure.

SQL
CREATE PROCEDURE DeleteUser (@UserId INT) AS BEGIN DELETE FROM Users WHERE Id = @UserId; [1] END;
Drag options to blanks, or click blank then click option'
AEND
BSTOP
CFINISH
DEXIT
Attempts:
3 left
💡 Hint
Common Mistakes
Using STOP or FINISH which are not valid SQL keywords
Using EXIT which is for control flow, not block ending
4fill in blank
hard

Fill both blanks to create a procedure that updates a user's email by their ID.

SQL
CREATE PROCEDURE UpdateEmail ([1] INT, [2] VARCHAR(100)) AS BEGIN UPDATE Users SET Email = @Email WHERE Id = @UserId; END;
Drag options to blanks, or click blank then click option'
A@UserId
B@Email
CUserId
DEmail
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting '@' in parameter names
Using parameter names that don't match the procedure body
5fill in blank
hard

Fill all three blanks to create a procedure that inserts a new user with name and age.

SQL
CREATE PROCEDURE AddUser ([1] VARCHAR(50), [2] INT) AS BEGIN INSERT INTO Users (Name, Age) VALUES ([3], @Age); END;
Drag options to blanks, or click blank then click option'
A@Name
B@Age
DName
Attempts:
3 left
💡 Hint
Common Mistakes
Using column names instead of parameter names in VALUES
Not prefixing parameters with '@'