MSSQL Interview Questions and answers
There are a dozen of editions of Microsoft SQL server in the market, which targets different audiences and workloads of all interfaces ranging from the small single interface applications to large interface application with lots of concurrent users.
With lots of scope in the industry, the candidates aiming to cruise with the knowledge of MSSQL can get an extra pair of hands with these interview questions to crack the interview.
1. What is MSSQL?
2. What is SQL server agent and what are the two modes of authentication in SQL Server?
The SQL Server agent plays an important part in the day to day tasks of the SQL Server Database Administrator (DBA).
Its purpose is to implement the tasks easily with the Scheduler engine that allows our tasks to run at a scheduled time and date.
Modes of Authentication in SQL Server
The two authentication modes in SQL Server are:
- Windows Mode
- Mixed Mode
From the tools menu of SQL Server configuration properties in the security page, the modes can be changed.
3. What is SQL Profiler?
4. What is COALESCE and CHECK constraint in SQL server?
CHECK constraint – It is used to enforce the integrity. It is applied to a column in a table to limit the values that have to be placed in a column.
5. Explain Subquery and state its properties?
- A subquery in the main query that has to be placed on the right-hand side of the comparison operator
- A subquery has to be placed parenthesis, in order to get executed first before the main query.
- It cannot have any order by clause.
- More than one subquery can be included in the main query.
6. What are types of subqueries?
- Single Row – It returns only one row.
- Multiple Row – It returns multiple rows.
- Multiple Column – It returns multiple columns to the main query.
7. Explain Trigger and its types?
They are automatically executed or triggered when the data gets modified.
Types of Triggers:
- Instead of
8. What do you mean by Collation recursive stored procedure?
- Case sensitive
- Case insensitive.
Recursive stored procedure – It is defined as a process of resolving a problem where the solution occurs repetitively.This can be nested up to 32 levels.
9. Explain Magic tables in SQL Server?
10. State the difference between Local and Global temporary tables?
Global temporary table – These tables are visible to all users and are deleted when the connection is closed.
11. Explain CDC and SQL injection?
SQL injection – SQL injection is an attack by malicious users in which the malicious code is inserted into the strings that are passed to an instance of SQL server for parsing and execution.
All the statements have to be checked for the vulnerabilities as they execute all syntactically valid queries received.The parameters can also be changed by the experienced and skilled attackers.
12. What methods do you follow to protect from SQL injection attack?
- Filtering input parameters
- Use parameter collection with Dynamic SQL
- Use Parameters for Stored procedures
- In like clause, use escape characters
13. What is filter index?
14. Distinguish between COMMIT and ROLLBACK?
ROLLBACK – Every statement between BEGIN and ROLLBACK are revealed to the state when the ROLLBACK is executed.
15. Explain Logical operators in SQL Server?
- ALL – It returns true if all the set of operations are true.
- AND – It returns true if the Boolean expressions are true.
- IN – It returns true if the operand is equal to one of the lists of expressions.
- ANY – It returns true if any of the set of comparisons is true.
- BETWEEN – It returns true if the operand is within a range.
- EXISTS – It returns true if the subquery contains any rows.
- LIKE – It returns true if the operand matches a pattern
- NOT – It reverses the values of any Boolean operator.
- OR – It returns true if either of the Boolean expression is true.
- SOME – It returns true if some of the set of comparisons are true.
16. Explain the commands in SQL Server?
DDL (Data Definition Language)
DCL (Data Control Language)
TCL (Transactional Control Language)
- Save Transaction
17. State the difference between UNION and UNION ALL?
It is similar to that of JOIN command.
UNION ALL – It is similar to that of UNION command, but it selects all the values.
It does not remove the values from the table but will retrieve the data.
18. Explain TABLESAMPLE?
19. What are the purposes of FLOOR and SIGN functions?
SIGN – It is used to determine whether the number provided is positive, Zero, negative and returns +1, 0, -1.
20. How are the exceptions handled in SQL Server Programming?