Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of the following script is an example of Quick detection in the SQL injection attack?(a) SELECT loginame FROM master..sysprocesses WHERE spid = SPID(b) For integer inputs : convert(int,version)(c) IF condition true-part ELSE false-part (S)(d) SELECT header, txt FROM news UNION ALL SELECT name, pass FROM membersThe question was asked in homework.I would like to ask this question from SQL Injection in chapter Developing with SQL Server of SQL Server

Answer»

Right choice is (b) For integer inputs : CONVERT(int,@@VERSION)

The best I can explain: Quick detection ATTACKS should THROW conversion errors.

2.

_______________ is time based SQL injection attack.(a) Quick detection(b) Initial Exploitation(c) Blind SQL Injection(d) Inline CommentsI had been asked this question in an interview for internship.My question is taken from SQL Injection topic in portion Developing with SQL Server of SQL Server

Answer»

Correct answer is (C) Blind SQL INJECTION

The BEST explanation: Blind SQL Injection is just like sleep, wait for SPECIFIED time.

3.

Point out the wrong statement.(a) SQL injection vulnerabilities occur whenever input is used in the construction of an SQL query without being adequately constrained or sanitized(b) SQL injection allows an attacker to access the SQL servers and execute SQL code under the privileges of the user used to connect to the database(c) The use of PL-SQL opens the door to these vulnerabilities(d) None of the mentionedThe question was asked in exam.I need to ask this question from SQL Injection in portion Developing with SQL Server of SQL Server

Answer»

Correct CHOICE is (C) The use of PL-SQL opens the DOOR to these vulnerabilities

The EXPLANATION is: Dynamic SQL (the construction of SQL QUERIES by concatenation of strings) opens the door to many vulnerabilities.

4.

Any user-controlled parameter that gets processed by the application includes vulnerabilities like ___________(a) Host-related information(b) Browser-related information(c) Application parameters included as part of the body of a POST request(d) All of the mentionedI have been asked this question in an interview.Question is from SQL Injection in division Developing with SQL Server of SQL Server

Answer»

Correct ANSWER is (d) All of the mentioned

For EXPLANATION I would say: SQL-injection exploit requires TWO things: an entry point and an exploit to ENTER.

5.

Which of the stored procedure used for dynamic SQL is prone to attacks?(a) xp_executesql(b) executesql(c) sp_execute(d) sp_executesqlI had been asked this question during an internship interview.Enquiry is from Dynamic SQL in section Developing with SQL Server of SQL Server

Answer»

Correct ANSWER is (d) sp_executesql

The explanation is: sp_executesql executes a Transact-SQL statement or batch that can be reused many times or one that has been built dynamically. RUN time-compiled Transact-SQL STATEMENTS can expose APPLICATIONS to MALICIOUS attacks.

6.

Which of the following is a disadvantage of dynamic SQL?(a) Stored procedure can not cache the execution plan for this dynamic query(b) Stored procedure can cache the execution plan for this dynamic query(c) Flexibility in your code that you can not get with standard SQL(d) All of the mentionedThis question was posed to me in an online quiz.This is a very interesting question from Dynamic SQL in section Developing with SQL Server of SQL Server

Answer»

Correct option is (a) Stored PROCEDURE can not cache the execution plan for this DYNAMIC QUERY

To explain I would say: Stored procedure can not cache the execution plan for this dynamic query. So, for COMPLEX queries you will lose the performance boost that you USUALLY gain with stored procedures.

7.

The basic syntax for using EXECUTE command is ___________(a) SP_EXECUTE(@SQLStatement)(b) EXEC_SQL(@SQLStatement)(c) EXECUTE(@SQLStatement)(d) All of the mentionedI had been asked this question in an interview for internship.This interesting question is from Dynamic SQL topic in section Developing with SQL Server of SQL Server

Answer» CORRECT choice is (C) EXECUTE(@SQLStatement)

To elaborate: EXECUTE COMMAND is DEMONSTRATED using :
8.

Point out the wrong statement.(a) The @stmt parameter in sp_executesql is a Unicode string containing valid SQL commands(b) The input type @Type is passed as the first parameter to sp_executesql(c) We can specify the parameters for both input and output in sp_executesql(d) None of the mentionedI got this question in semester exam.I would like to ask this question from Dynamic SQL topic in section Developing with SQL Server of SQL Server

Answer» CORRECT choice is (B) The INPUT type @Type is passed as the first PARAMETER to sp_executesql

To EXPLAIN: The output type @retType is passed as the second parameter to sp_executesql.
9.

The Dynamic SQL Queries in a variable are __________ until they are executed.(a) Compiled(b) Parsed(c) Checked for errors(d) All of the mentionedI had been asked this question during a job interview.My doubt stems from Dynamic SQL in portion Developing with SQL Server of SQL Server

Answer» RIGHT CHOICE is (d) All of the mentioned

Easiest EXPLANATION: A Dynamic SQL is needed when we NEED to RETRIEVE a set of records based on different search parameters.
10.

Which of the following is a calling syntax for sp_executesql?(a) sp_execute [,, …](b) sp_sql [,, …](c) sp_executesql [,, …](d) sp_executesql [,, …]I had been asked this question by my college director while I was bunking the class.This is a very interesting question from Dynamic SQL topic in division Developing with SQL Server of SQL Server

Answer»

The correct answer is (c) sp_executesql <@stmt> [<@param1 data_type>,<@param2 data_type>, …]

For explanation I would say: Using sp_executesql to run DYNAMIC statements GIVES us a COUPLE ADVANTAGES over EXEC that are worth noting.

11.

Dynamic SQL Statements in SQL Server can be easily built using ________________(a) Cursor(b) Stored procedure(c) Function(d) All of the mentionedThe question was asked in a job interview.This question is from Dynamic SQL in portion Developing with SQL Server of SQL Server

Answer»

Right option is (b) STORED procedure

Explanation: Dynamic SQL is a term used to mean SQL code that is generated programmatically (in PART or fully) by your PROGRAM before it is EXECUTED.

12.

Point out the correct statement.(a) ODBC has the call ExecDirect(b) Few database systems provide the facilities for running SQL code directly against the database engine(c) The SQL code is not stored in the source program, but rather it is generated based on user input(d) None of the mentionedThis question was posed to me by my college professor while I was bunking the class.The above asked question is from Dynamic SQL in division Developing with SQL Server of SQL Server

Answer»

Correct CHOICE is (c) The SQL code is not stored in the source program, but rather it is generated BASED on user input

Easiest explanation: The SQL code can include determining not only what objects are involved, but also the filter criteria and other QUALIFIERS that define the set of data being acted on.

13.

Which of the following is a way to build dynamic sql statements?(a) Writing a query with parameters(b) Using sp_executesql(c) Using EXEC(d) All of the mentionedThis question was posed to me in homework.Enquiry is from Dynamic SQL topic in chapter Developing with SQL Server of SQL Server

Answer»

Right choice is (d) All of the mentioned

The explanation is: SQL Server offer THREE WAYS of running a dynamically built SQL STATEMENT.

14.

Scope of DDL triggers in SQL Server can be _____________(a) Server(b) Client(c) Views(d) None of the mentionedThe question was posed to me during an interview for a job.My question comes from DDL Triggers in section Developing with SQL Server of SQL Server

Answer» RIGHT choice is (a) Server

Best EXPLANATION: DDL triggers can be server-scoped or DATABASE-scoped. A database-scoped DDL TRIGGER is simply called a database trigger.
15.

____________ triggers do not create the special inserted and deleted tables.(a) DML(b) CLR(c) DDL(d) All of the mentionedThis question was addressed to me in homework.I'd like to ask this question from DDL Triggers in division Developing with SQL Server of SQL Server

Answer»

Right option is (C) DDL

Explanation: DDL triggers do not fire in response to events that affect LOCAL or global temporary TABLES and stored PROCEDURES.

16.

How many types of DDL Trigger is present in SQL Server?(a) 1(b) 2(c) 3(d) 4This question was addressed to me by my school teacher while I was bunking the class.I'm obligated to ask this question of DDL Triggers topic in chapter Developing with SQL Server of SQL Server

Answer»

The correct CHOICE is (B) 2

Easy EXPLANATION: Transact-SQL DDL TRIGGER and CLR DDL Trigger are two types of DDL Trigger.

17.

DDL triggers can only fire after the ______ statement has occurred.(a) DML(b) CLR(c) DDL(d) All of the mentionedI got this question during an interview for a job.The origin of the question is DDL Triggers in portion Developing with SQL Server of SQL Server

Answer»

The CORRECT option is (c) DDL

For explanation: DDL Triggers can be set with either a SERVER SCOPE or DATABASE scope.

18.

Purpose of DDL Trigger is to _____________(a) Perform administrative tasks(b) Audit(c) Regulating database operations(d) All of the mentionedThis question was addressed to me in final exam.My enquiry is from DDL Triggers in portion Developing with SQL Server of SQL Server

Answer» CORRECT choice is (d) All of the mentioned

For EXPLANATION I would say: DDL triggers fire in response to a variety of Data DEFINITION Language (DDL) events.
19.

Point out the wrong statement.(a) DDL trigger can be used to observe and control actions performed on the server, and to audit these operations(b) DML trigger can be used to observe and control actions performed on the server, and to audit these operations(c) DDL triggers can be used to manage administrator tasks such as auditing and regulating database operations(d) None of the mentionedThe question was posed to me in final exam.I want to ask this question from DDL Triggers topic in division Developing with SQL Server of SQL Server

Answer»

Correct answer is (b) DML trigger can be used to observe and control actions PERFORMED on the server, and to audit these operations

The explanation: DDL TRIGGERS are a special kind of trigger that fire in RESPONSE to DATA DEFINITION Language (DDL) statements.

20.

INSTEAD of clause cannot be used for ____________ trigger.(a) DML(b) DDL(c) LOGON(d) CLRThis question was posed to me in final exam.I need to ask this question from DDL Triggers topic in portion Developing with SQL Server of SQL Server

Answer»

The correct choice is (b) DDL

To EXPLAIN I WOULD SAY: We can use only FOR/AFTER CLAUSE in DDL triggers not INSTEAD OF clause means we can make only After TRIGGER on DDL statements.

21.

DDL triggers can be applied to __________ statement.(a) CREATE(b) UPDATE(c) DELETE(d) INSERTI had been asked this question during an interview.My question is based upon DDL Triggers topic in portion Developing with SQL Server of SQL Server

Answer» RIGHT choice is (a) CREATE

For EXPLANATION I WOULD say: In SQL Server we can create triggers on DDL statements (LIKE CREATE, ALTER, and DROP).
22.

Point out the correct statement.(a) Logon triggers are special type of trigger that fire when LOGON event of Sql Server is raised(b) DDL triggers are special type of trigger that fire when LOGON event of Sql Server is raised(c) DML triggers are special type of trigger that fire when LOGON event of Sql Server is raised(d) None of the mentionedThis question was posed to me by my school teacher while I was bunking the class.This interesting question is from DDL Triggers topic in portion Developing with SQL Server of SQL Server

Answer»

Correct answer is (a) Logon TRIGGERS are SPECIAL type of trigger that FIRE when LOGON EVENT of Sql Server is raised

To explain: Logon event is raised when a user session is being established with Sql Server that is made after the authentication phase finishes.

23.

Triggers can be enabled or disabled with the ________ statement.(a) ALTER TABLE statement(b) DROP TABLE statement(c) DELETE TABLE statement(d) None of the mentionedI had been asked this question in an interview for job.This is a very interesting question from DML Triggers in section Developing with SQL Server of SQL Server

Answer» CORRECT option is (a) ALTER TABLE statement

To elaborate: You can ALSO use the ALL keyword instead of a trigger name to enable/disable all of the triggers on a table in QUESTION.
24.

_____________ is special type of trigger based on CLR environment.(a) DML(b) DDL(c) LOGON(d) CLRI got this question in exam.My question comes from DDL Triggers topic in chapter Developing with SQL Server of SQL Server

Answer»

Right option is (d) CLR

For explanation I would say: CLR INTEGRATION of triggers has been introduced with SQL Server 2008 and allows for triggers to be CODED in one of .NET languages LIKE C#, Visual Basic and F#.

25.

Which of the following is not a typical trigger action?(a) Insert(b) Select(c) Delete(d) All of the mentionedThis question was addressed to me during an interview for a job.This is a very interesting question from DML Triggers in section Developing with SQL Server of SQL Server

Answer»

Right ANSWER is (B) Select

The best EXPLANATION: Valid trigger actions are INSERT, UPDATE and DELETE, or a combination of several, separated by commas.

26.

Triggers created with FOR or AFTER keywords is _____________(a) AFTER(b) INSTEAD OF(c) CLR(d) All of the mentionedI have been asked this question in examination.I'm obligated to ask this question of DML Triggers topic in chapter Developing with SQL Server of SQL Server

Answer» RIGHT OPTION is (a) AFTER

To ELABORATE: AFTER TRIGGERS do not WORK for views.
27.

AFTER trigger in SQL Server can be applied to _________________(a) Table(b) Views(c) Table and Views(d) FunctionI got this question by my college director while I was bunking the class.Enquiry is from DML Triggers topic in chapter Developing with SQL Server of SQL Server

Answer»

Correct choice is (C) Table and Views

The explanation: AFTER trigger FIRES after SQL Server COMPLETES the EXECUTION of the action successfully that fired it.

28.

DML triggers in SQL Server is applicable to _____________(a) Insert(b) Update(c) Delete(d) All of the mentionedThis question was posed to me by my school principal while I was bunking the class.My question is based upon DML Triggers in portion Developing with SQL Server of SQL Server

Answer»

Right answer is (d) All of the mentioned

For explanation I would say: In SQL Server we can create triggers on DML statements (like INSERT, UPDATE, and DELETE) and stored procedures that PERFORM DML-like OPERATIONS.

29.

Point out the wrong statement.(a) We can have an INSTEAD OF insert/update/delete trigger on a table that successfully executed(b) DML Triggers are used to evaluate data after data manipulation using DML statements(c) INSTEAD OF triggers cause their source DML operation to skip(d) AFTER triggers cause their source DML operation to skipThis question was addressed to me in an online interview.The origin of the question is DML Triggers topic in section Developing with SQL Server of SQL Server

Answer»

The correct choice is (d) AFTER TRIGGERS CAUSE their SOURCE DML operation to skip

The best explanation: INSTEAD OF triggers cause their source DML operation to skip and they just execute the code provided inside them.

30.

How many types of DML triggers are present in SQL Server?(a) 1(b) 3(c) 5(d) None of the mentionedI got this question during a job interview.My doubt stems from DML Triggers in portion Developing with SQL Server of SQL Server

Answer» RIGHT answer is (d) NONE of the mentioned

The best EXPLANATION: We have two types of DML triggers-AFTER and INSTEAD OF.
31.

How many types of triggers are present in SQL Server?(a) 4(b) 5(c) 8(d) 9This question was posed to me by my school principal while I was bunking the class.The above asked question is from DML Triggers in chapter Developing with SQL Server of SQL Server

Answer» RIGHT CHOICE is (a) 4

Easiest explanation: In SQL Server we can create four types of TRIGGERS Data Definition Language (DDL) triggers, Data Manipulation Language (DML) triggers, CLR triggers and Logon triggers.
32.

Point out the correct statement.(a) Triggers are database object(b) Three types of triggers are present in SQL Server(c) A DDL trigger is an action programmed to execute when a data manipulation language (DML) event occurs in the database server(d) None of the mentionedThis question was addressed to me during an online exam.My question is taken from DML Triggers topic in chapter Developing with SQL Server of SQL Server

Answer»

The CORRECT option is (a) Triggers are database object

Easiest explanation: Triggers are special type of stored PROCEDURE that AUTOMATICALLY executes when a DDL or DML statement associated with the trigger is EXECUTED.

33.

Trigger is special type of __________ procedure.(a) Stored(b) Function(c) View(d) TableI have been asked this question by my college professor while I was bunking the class.This is a very interesting question from DML Triggers in portion Developing with SQL Server of SQL Server

Answer» CORRECT choice is (a) Stored

Explanation: TRIGGERS are used to assess/evaluate data before or after data MODIFICATION USING DDL and DML statements.
34.

The ability to create a user-defined function (UDF) is a new feature added to ________________(a) SQL Server 6.5(b) SQL Server 7.0(c) SQL Server 2000(d) None of the mentionedI had been asked this question in semester exam.My doubt stems from User Defined Functions topic in portion Developing with SQL Server of SQL Server

Answer» CORRECT answer is (c) SQL Server 2000

The best explanation: A user-defined function is a database object that encapsulates one or more Transact-SQL statements for REUSE. DEVELOPERS have been asking Microsoft to ADD this FEATURE for several versions of the product.
35.

Which of the user defined function will be preferred for adding two numbers?(a) Scalar(b) Inline table valued(c) Max()(d) Min()This question was posed to me by my school principal while I was bunking the class.The doubt is from User Defined Functions topic in chapter Developing with SQL Server of SQL Server

Answer» RIGHT ANSWER is (a) Scalar

To ELABORATE: We are can create a Scalar UDF AddTwoNumbers which accepts two input parameters @a and @B and returns OUTPUT as the sum of the two input parameters.
36.

When to choose scalar function over inline table valued function?(a) You want a single value as the result(b) One or more row’s worth of data is expected(c) You want multiple values asresult(d) All of the mentionedThe question was posed to me in my homework.I would like to ask this question from User Defined Functions topic in division Developing with SQL Server of SQL Server

Answer» CORRECT choice is (a) You want a single VALUE as the RESULT

To EXPLAIN I would say: For an inline scalar function, there is no function body; the scalar value is the result of a single STATEMENT.
37.

UDFs in SQL Server is composed of _______ parts.(a) 1(b) 2(c) 3(d) 4The question was posed to me during an interview.The above asked question is from User Defined Functions topic in division Developing with SQL Server of SQL Server

Answer»

Correct OPTION is (B) 2

Easiest EXPLANATION: UDFs are composed of two parts:HEADER and FUNCTION body.

38.

Which of the following is the most visible benefit of user-defined function?(a) Slow performance(b) Bad optimized queries(c) Faster performance(d) All of the mentionedI got this question in an online quiz.Query is from User Defined Functions in division Developing with SQL Server of SQL Server

Answer»

The correct choice is (C) Faster performance

Easiest explanation: T-SQL FUNCTIONS are great at processing data. When it COMES to BUSINESS logic and custom ALGORITHMS, UDFs can do a much better job. UDFs work was akin to stored procedures.

39.

Point out the wrong statement.(a) If the function specifies a user-defined type, requires EXECUTE permission on the type(b) If the function specifies a user-defined type, requires READ permission on the type(c) If the function specifies a user-defined type, requires ALTER permission on the type(d) None of the mentionedThe question was posed to me during an internship interview.Query is from User Defined Functions topic in section Developing with SQL Server of SQL Server

Answer» CORRECT ANSWER is (B) If the function specifies a user-defined TYPE, requires READ permission on the type

Easiest EXPLANATION: Function creation requires ALTER and EXECUTE permission.
40.

Which of the following statements cannot be included in the definition of a Transact-SQL user-defined function?(a) GET CONVERSATION GROUP(b) MOVE CONVERSATION(c) RECEIVE(d) All of the mentionedThis question was addressed to me in a job interview.Query is from User Defined Functions topic in division Developing with SQL Server of SQL Server

Answer»

The CORRECT option is (d) All of the mentioned

The BEST explanation: Most of the Service broker STATEMENTS cannot be included in the definition of a Transact-SQL user-defined FUNCTION.

41.

CREATE FUNCTION requires __________ permission in the database.(a) ALTER(b) DROP(c) DELETE(d) All of the mentionedThe question was posed to me during an online exam.Asked question is from User Defined Functions topic in chapter Developing with SQL Server of SQL Server

Answer»

Correct answer is (a) ALTER

For explanation: ALTER permission is required on the SCHEMA in which the FUNCTION is being created.

42.

Point out the correct statement.(a) User-defined functions cannot be used to perform actions that modify the database state(b) User-defined functions cannot contain an OUTPUT INTO clause that has a table as its target(c) User-defined functions can not return multiple result sets. Use a stored procedure if you need to return multiple result sets(d) All of the mentionedThis question was addressed to me in an internship interview.I want to ask this question from User Defined Functions topic in portion Developing with SQL Server of SQL Server

Answer»

Right answer is (d) All of the mentioned

For explanation: Transact-SQL ERRORS that CAUSE a statement to be canceled and continue with the next statement in the MODULE (such as TRIGGERS or stored PROCEDURES) are treated differently inside a function.

43.

Which of the following is not a limitation of user defined function?(a) User-defined functions cannot call a stored procedure, but can call an extended stored procedure(b) User-defined functions cannot make use of dynamic SQL or temp tables. Table variables are allowed(c) SET statements are allowed in a user-defined function(d) The FOR XML clause is not allowedThe question was asked during an interview for a job.Question is from User Defined Functions topic in division Developing with SQL Server of SQL Server

Answer»

The correct CHOICE is (C) SET STATEMENTS are allowed in a user-defined function

Explanation: SET statements are allowed in a user-defined function.

44.

User defined scalar function can return only __________ data type values.(a) Numerical(b) String(c) Float(d) All of the mentionedI have been asked this question in examination.My enquiry is from User Defined Functions in portion Developing with SQL Server of SQL Server

Answer»

The correct choice is (d) All of the mentioned

For EXPLANATION: We RETURN any data type value from FUNCTION.

45.

Which of the following is not a User defined function?(a) Max()(b) Scalar Function(c) Inline Table-Valued Function(d) Multi-Statement Table-Valued FunctionThis question was posed to me during an online interview.This key question is from User Defined Functions in section Developing with SQL Server of SQL Server

Answer»

The CORRECT answer is (a) Max()

The best I can EXPLAIN: max() is system defined AGGREGATE function.

46.

Which of the following does not return a table variable?(a) System-defined function(b) Scalar Function(c) Inline Table-Valued Function(d) Multi-Statement Table-Valued FunctionThis question was addressed to me in class test.Question is taken from User Defined Functions topic in section Developing with SQL Server of SQL Server

Answer» RIGHT OPTION is (B) Scalar Function

Explanation: User-defined multi-statement table-valued function returns a table VARIABLE as a result of actions performed by the function.
47.

How many types of user defined function is provided by SQL Server?(a) 2(b) 3(c) 4(d) 5I have been asked this question in unit test.This is a very interesting question from User Defined Functions topic in section Developing with SQL Server of SQL Server

Answer»

Right choice is (B) 3

To EXPLAIN I would say: USER Defined functions are created by the user in the system database or in the user-defined database and there are three types of user-defined functions.

48.

Syntax for creation of user defined function is ____________(a) CREATE FUNCTIONS(b) CREATE FUNCTION(c) CREATE FUNC(d) All of the mentionedI got this question in an online quiz.This is a very interesting question from User Defined Functions topic in section Developing with SQL Server of SQL Server

Answer»

The correct ANSWER is (B) CREATE FUNCTION

To explain: If a CREATE FUNCTION statement produces side effects against resources that do not EXIST when the CREATE FUNCTION statement is ISSUED.

49.

Point out the wrong statement.(a) Transact-SQL user-defined functions in queries can only be executed on a multiple thread(b) User-defined scalar functions return a single data value of the type defined in the RETURNS clause(c) User-defined table-valued functions return a table data type(d) All of the mentionedThis question was posed to me in class test.My question is based upon User Defined Functions in chapter Developing with SQL Server of SQL Server

Answer»

Right OPTION is (a) Transact-SQL user-defined functions in queries can only be executed on a multiple thread

The best I can explain: Transact-SQL user-defined functions in queries can only be executed on a SINGLE thread (serial execution PLAN).

50.

Point out the wrong statement.(a) You can create the function once, store it in the database(b) CLR functions offer significant performance advantage over Transact-SQL functions for computational task(c) Function is a database object in Sql Server(d) None of the mentionedI got this question during a job interview.I would like to ask this question from User Defined Functions in section Developing with SQL Server of SQL Server

Answer»

The CORRECT choice is (d) None of the mentioned

To EXPLAIN I WOULD say: Function is a SET of sql statements that accepts only input parameters, perform actions and RETURN the result.