MCQ – Multiple choice questions on stored procedure sql and function with answers and explanation. Objective questions are asked in Software jobs written interviews.
Q) A stored procedure in SQL is a___________
- Block of functions
- Group of SQL statements.
- None
Answer: 2
Q) Advantage of SQL stored procedure
- Maintainability
- Re-use of code
- Security
- All
Answer: 4
Q) Syntax to create stored procedure is/are
-
CREATE PROCEDURE procedureName AS SQL statements
-
CREATE PROCEDURE procedureName AS BEGIN SQL statements END
-
CREATE PROC procedureName AS BEGIN SQL statements END
- B & C
- B only
Answer: 4
Q) Which statement(S) is/are incorrect
- Stored procedure may return a value and function must return a value.
- Function has only IN parameter.
- Try and Catch can be used with both stored procedure and function.
- Stored procedure has IN and OUT parameter.
Answer: 3
Q) Which statement(S) is/are incorrect
- Stored procedure can be shared by multiple programs
- Stored procedures are in compiled form.
- Stored procedure is a group of SQL statements
- All are correct.
Answer: 4
Q) Which SQL Queries to execute stored procedure given below is/are incorrect
Create Procedure spGetStudentByGenderAndAge
@Gender nvarchar(10), @Age int
As
Begin
Select Name, Gender, Age from tblStudent Where Gender = @ Gender
And Age = @ Age
End
- spGetStudentByGenderAndAge 1, ‘male’
- spGetStudentByGenderAndAge ‘male’ 1
- spGetStudentByGenderAndAge @ Age =1, @ Gender =’male’
- spGetStudentByGenderAndAge @ Gender =’male’, @ Age =1
Answer : A.
Error converting nvarchar to int. Rest are fine.