0% found this document useful (0 votes)
19 views6 pages

Developer Interview Questions

Uploaded by

Murali Pujari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
19 views6 pages

Developer Interview Questions

Uploaded by

Murali Pujari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 6

1. What are the different types of joins in SQL Server?

 SQL Server supports several types of joins including INNER JOIN, LEFT
JOIN (or LEFT OUTER JOIN), RIGHT JOIN (or RIGHT OUTER JOIN), and FULL
JOIN.
2. Explain the differences between CHAR, VARCHAR, and NVARCHAR data
types in SQL Server.
 CHAR is a fixed-length character data type, while VARCHAR is a variable-
length character data type. NVARCHAR is used to store Unicode character
data.
 CHAR and VARCHAR are limited to non-Unicode characters, whereas
NVARCHAR can store both Unicode and non-Unicode characters.
3. What is a clustered index and how does it differ from a non-clustered index?
 A clustered index determines the physical order of rows in a table based
on the indexed column(s). Each table can have only one clustered index.
 A non-clustered index is a separate structure from the table and contains a
sorted list of references to the table's rows. Multiple non-clustered indexes
can exist on a table.
4. Explain the purpose of the GROUP BY clause in SQL Server.
 The GROUP BY clause is used to group rows that have the same values
into summary rows, typically to perform aggregate functions (e.g., SUM,
COUNT, AVG) on each group.
5. What is the purpose of the HAVING clause in SQL Server?
 The HAVING clause is used in conjunction with the GROUP BY clause to
filter groups based on specified conditions after the grouping has been
done.
6. What is a stored procedure in SQL Server?
 A stored procedure is a precompiled collection of SQL statements and
procedural logic that is stored in the database and can be executed
multiple times.
7. How do you handle errors in stored procedures in SQL Server?
 Errors in stored procedures can be handled using TRY...CATCH blocks to
catch and handle exceptions gracefully, allowing for rollback of
transactions if necessary.
8. Explain the purpose of the @@IDENTITY and SCOPE_IDENTITY() functions in
SQL Server.
 @@IDENTITY returns the last identity value generated for any table in the
current session, while SCOPE_IDENTITY() returns the last identity value
generated within the current scope (e.g., within the current stored
procedure, trigger, or function).
9. What is a Common Table Expression (CTE) in SQL Server?
 A Common Table Expression (CTE) is a temporary result set that can be
referenced within a SELECT, INSERT, UPDATE, or DELETE statement. It helps
in simplifying complex queries and improving readability.
10. Explain the purpose of the MERGE statement in SQL Server.
 The MERGE statement allows you to perform INSERT, UPDATE, and DELETE
operations in a single statement based on the results of a join between a
target table and a source table.
11. What is the purpose of the INDEX hint in SQL Server?
 The INDEX hint allows you to specify which index should be used by the
query optimizer when executing a query, providing more control over
query execution plans.
12. What is the purpose of the NOLOCK hint in SQL Server?
 The NOLOCK hint, also known as READUNCOMMITTED, allows a query to
read data without acquiring locks on the underlying tables, potentially
improving query performance at the risk of reading uncommitted data.
13. What is the difference between UNION and UNION ALL in SQL Server?
 UNION removes duplicate rows from the result set, while UNION ALL
includes all rows, including duplicates, in the result set.
14. Explain the purpose of the ROW_NUMBER() function in SQL Server.
 The ROW_NUMBER() function assigns a unique sequential integer to each
row in the result set based on the specified ordering. It is commonly used
for pagination or ranking purposes.
15. What is the purpose of the PIVOT and UNPIVOT operators in SQL Server?
 PIVOT rotates rows into columns based on specified column values, while
UNPIVOT performs the opposite operation, rotating columns into rows.
16. What is the purpose of the EXISTS and NOT EXISTS operators in SQL Server?
 EXISTS is used to check for the existence of rows returned by a subquery,
while NOT EXISTS is used to check for the absence of rows returned by a
subquery.
17. What is SQL injection and how can it be prevented in SQL Server?
 SQL injection is a security vulnerability that occurs when untrusted input is
inserted into SQL queries, allowing attackers to execute malicious SQL
code.
 It can be prevented by using parameterized queries, stored procedures,
input validation, and proper user permissions.
18. Explain the purpose of the XML data type in SQL Server.
 The XML data type allows you to store XML data in a structured format
within SQL Server, enabling efficient storage, retrieval, and manipulation of
XML data.
19. What is the purpose of the TRY_PARSE function in SQL Server?
 The TRY_PARSE function attempts to convert a string representation of a
value to the specified data type, returning NULL if the conversion fails
instead of throwing an error.
20. How do you optimize query performance in SQL Server?
 Query performance can be optimized by creating appropriate indexes,
minimizing table scans, avoiding unnecessary joins, using parameterized
queries, updating statistics, and optimizing query execution plans.

21. What are the different types of constraints in SQL Server?

 Constraints are rules enforced on data columns to maintain integrity. SQL


Server supports various types of constraints including PRIMARY KEY,
FOREIGN KEY, UNIQUE, CHECK, and DEFAULT constraints.

22. Explain the difference between the TRUNCATE TABLE and DELETE
statements in SQL Server.

 TRUNCATE TABLE removes all rows from a table, but it does not log
individual row deletions, making it faster and less resource-intensive than
DELETE, which removes rows one by one and logs each deletion.

23. What is the purpose of the ROWLOCK and PAGELOCK hints in SQL Server?

 ROWLOCK hint instructs the SQL Server query optimizer to use row-level
locking, whereas PAGELOCK hint instructs it to use page-level locking.
These hints can be used to control the granularity of locks acquired during
query execution.

24. Explain the purpose of the XML PATH() function in SQL Server.

 The XML PATH() function is used to concatenate values from multiple rows
into a single string, formatted as XML. It is commonly used for string
aggregation in SQL Server.

25. What is the purpose of the SET NOCOUNT ON statement in SQL Server?
 SET NOCOUNT ON statement prevents the message indicating the
number of rows affected by a Transact-SQL statement from being returned
as part of the result set. This can reduce network traffic and improve
performance, especially in environments with high transaction rates.

26. Explain the purpose of the STUFF() function in SQL Server.

 The STUFF() function is used to delete a specified length of characters


from a string and then insert another string at a specified starting point. It
is commonly used for string manipulation tasks.

27. What is the purpose of the ROLLUP and CUBE operators in SQL Server?

 ROLLUP generates subtotals and grand totals for a group of rows, while
CUBE generates subtotals and grand totals for all possible combinations of
grouping columns. These operators are used with the GROUP BY clause for
multi-level aggregation.

28. Explain the purpose of the FILESTREAM feature in SQL Server.

 FILESTREAM is a feature in SQL Server that enables storage of and efficient


access to large binary data (e.g., documents, images, videos) using the file
system instead of storing them directly in the database. This helps in
managing large binary data while leveraging SQL Server's transactional
capabilities.

29. What is the purpose of the OVER clause in SQL Server?

 The OVER clause is used to define window functions, which perform


calculations across a set of rows related to the current row within a query
result set. Window functions can be used to calculate running totals, ranks,
and moving averages, among other things.

30. Explain the purpose of the LEAD and LAG functions in SQL Server.

 The LEAD function is used to access data from subsequent rows within the
same result set, while the LAG function is used to access data from
preceding rows. These functions are often used for time-series analysis
and to compare values across adjacent rows.
31. Explain the purpose of the PERSISTED keyword in SQL Server.

 The PERSISTED keyword is used when creating computed columns in SQL


Server. It indicates that the computed value should be stored physically on
disk, rather than being recalculated each time the column is referenced in
a query. This can improve query performance, especially for frequently
used computed columns.

32. What is the purpose of the FILEGROUP in SQL Server?

 FILEGROUP is a logical container for storing database files (.mdf, .ndf). It


allows you to group multiple data files together and assign specific data to
each group. FILEGROUPs are often used for managing database objects
across multiple disks for better performance, scalability, and
manageability.

33. What is the purpose of the CROSS APPLY and OUTER APPLY operators in SQL
Server?

 CROSS APPLY and OUTER APPLY operators are used to invoke a table-valued
function for each row returned by the outer query. CROSS APPLY returns only
the rows for which there is a match between the left and right table expressions,
while OUTER APPLY returns all rows from the left table expression and NULLs
for unmatched rows.

34. Explain the purpose of the SQL Server Agent and how it is used.

 SQL Server Agent is a component of SQL Server that automates administrative


tasks, such as database backups, maintenance plans, and job scheduling. It allows
users to schedule and execute tasks at specified intervals or in response to certain
events.

35. What are the different recovery models available in SQL Server, and how do they
differ?

 SQL Server supports three recovery models: Simple, Full, and Bulk-Logged.
 Simple recovery model logs minimal information, allowing for easy management
of transaction logs but providing limited recovery options.
 Full recovery model logs all changes to the database, enabling point-in-time
recovery but requiring regular transaction log backups.
 Bulk-Logged recovery model is similar to Full recovery model but minimally logs
bulk operations, reducing log space usage during bulk operations.
36. Explain the purpose of the SQL Server Profiler tool.

 SQL Server Profiler is a graphical tool used to monitor and capture events and
activities occurring in SQL Server, such as queries, stored procedure calls, and
errors. It helps database administrators and developers analyze database
performance, diagnose issues, and optimize queries.

37. What is the purpose of the SQL Server Reporting Services (SSRS)?

 SQL Server Reporting Services (SSRS) is a server-based reporting platform that


allows users to create, manage, and deliver interactive and paginated reports. It
provides tools for designing reports, scheduling report execution, and accessing
reports via web browsers or mobile devices.

38. Explain the purpose of the SQL Server Integration Services (SSIS).

 SQL Server Integration Services (SSIS) is a platform for building enterprise-level


data integration and workflow solutions. It enables users to extract, transform, and
load (ETL) data from various sources to destinations, automate administrative
tasks, and perform data cleansing and migration.

39. What is the purpose of the SQL Server Analysis Services (SSAS)?

 SQL Server Analysis Services (SSAS) is a multidimensional and data mining tool
used for online analytical processing (OLAP) and data mining tasks. It allows
users to design and deploy analytical models, create cubes and data mining
structures, and perform advanced analytics on large datasets.

40. Explain the purpose of the SQL Server Always On Availability Groups feature.

 SQL Server AlwaysOn Availability Groups is a high-availability and disaster


recovery solution that provides database-level redundancy and automatic failover
capabilities. It allows users to create groups of databases that fail over together,
ensuring continuous availability and data protection.

You might also like