Tech Point Fundamentals

Sunday, March 5, 2023

SQL Interview Questions and Answers List

SQL Interview Questions and Answers List

sql-interview-questions-list

Are you preparing for the SQL Interview? If yes, then you are at the right place. This is the SQL Interview Questions and Answers article series. Here we will see the Top 100+ SQL Interview Questions with Answers.  

Please visit our YouTube Channel for Interviews and other videos by below link:



Introduction


I have already posted all the SQL Interview Questions and Answers article series. Here we will see the SQL Interview Questions Summary and the particular part link so that you can walk through the answer to the particular interview question directly.

Please read the following important Interview Questions and Answers article series here: 






SQL Interview Questions And Answers List 



Part 01: https://www.techpointfunda.com/2022/03/sql-interview-part-01.html


Q01. What is Normalization in SQL?
Q02. What are the different Normal Forms (NF) in SQL?
Q03. What is DeNormalization and why do we need it?
Q04. What is the 8KB Page Concept in SQL?
Q05. What is the IAM Page in SQL?
Q06. What is Heap in SQL?
Q07. What is the difference between Table Scan vs Index Scan vs Index Seek?
Q08. What is Fragmentation or Index Fragmentation in SQL?






Part 02https://www.techpointfunda.com/2022/03/sql-interview-part-02.html


Q09. What is the SQL Profiler?
Q10. What is SQL Server Agent?
Q11. What are the MASTER and TEMPDB databases? What is the use of these databases?
Q12. Which TCP/IP port does SQL Server run on? How can you change it?
Q13. What is a Linked Server? How can you create it?
Q14. What are the different authentication modes in SQL Server? What are the different SQL Login Types?
Q15. What is Collation in SQL? How does it affect the database?
Q16. What is the use of Statistics? Why the updation of statistics are important in SQL?







Q17. What is Constraint in SQL Server? What are the different types of Constraints available in SQL Server?
Q18. What is the Primary Key Constraint in SQL Server?
Q19. What is the difference between Primary Key vs Clustered Index?
Q20. What is the Unique Key Constraint in SQL Server?
Q21. What is the difference between Unique Key vs Unique Index?
Q22. What is the difference between Primary Key and Unique Key?
Q23. What is NOT NULL Constraint?
Q24. What is Default Constraint?






Part 04https://www.techpointfunda.com/2022/03/sql-interview-part-04.html


Q25. What is CHECK Constraint in SQL Server?
Q26. What is Foreign Key Constraint in SQL Server?
Q27. How the Foreign Key works? or How the Foreign Key preserves the Referential Integrity?
Q28. What is the difference between Primary Key vs Foreign Key?
Q29. What is the difference between Foreign Key Constraint vs Check Constraint?
Q30. What is an index and what are the different types of indexes in SQL?
Q31. What is the difference between  Clustered Index vs Non-Clustered Index in SQL Server?
Q32. What is the difference between Constraint vs Index?







Q33. What is the difference between Unicode data types and Non-Unicode data types?
Q34. What is the difference between fixed-length data type and variable-length data type?
Q35. What is the difference between CHAR vs VARCHAR data types?
Q36. What is the difference between VARCHAR vs NVARCHAR data types?
Q37. What is the max size of a VARCHAR and NVARCHAR data type in SQL, Why? 
Q38. What is the difference between VARCHAR(MAX) and VARCHAR(n) data types?
Q39. What is the difference between VARCHAR(MAX) and TEXT(n) data types?
Q40. What is the difference between LEN() vs DATALENGTH() in SQL?
Q41. What is the difference between DateTime and DateTime2 data types in SQL?






Part 06https://www.techpointfunda.com/2022/07/sql-interview-part-06.html


Q42. What is the difference between CAST vs. CONVERT in SQL?
Q43. What does it mean to have QUOTED_IDENTIFIER ON in SQL?
Q44. What does it mean to have ANSI_NULL ON or OFF in SQL?
Q45. What does it mean to have ANSI_PADDING ON or OFF in SQL?
Q46. What is the difference between GO and Semicolon(;) Statement Terminator in SQL?
Q47. What is NULL in SQL? What is the difference between NULL and UNKNOWN?
Q48. What is SQL Three Valued Logic? How does it affect the application logic?
Q49. What is the difference between ISNULL() vs COALESCE() function?







Part 07https://www.techpointfunda.com/2022/07/sql-interview-part-07.html


Q50. What is the difference between DELETE vs TRUNCATE command?
Q51. What is the difference between the WHERE clause vs HAVING clause in SQL Server?
Q52. What is the difference between COUNT(*) vs COUNT(col) vs COUNT(1) in SQL?
Q53. What is the difference between UNION vs UNION ALL in SQL?
Q54. How can you get the last inserted record in SQL? OR What is the difference between @@IDENTITY, SCOPE_IDENTITY(), and IDENT_CURRENT() in SQL?
Q55. What is the difference between ROW_NUMBER() vs  RANK() vs DENSE_RANK() in SQL?
Q56. What is the main difference between IN() vs NOT IN() operators in SQL?
Q57. What is the difference between SQL INTERSECT vs EXCEPT operator?
Q58. What is the difference between IN() vs EXIST() operators?
Q59. What is the difference between NOT IN() vs NOT EXISTS() vs EXCEPT operator?







Part 08https://www.techpointfunda.com/2022/07/sql-interview-part-08.html


Q60. What is SubQuery? What is the difference between Standalone SubQuery, Co-Related SubQuery, and Nested SubQuery in SQL?
Q61. What is a Temporary Table or Temp Table in SQL? What is the difference between Local Temp Table and Global Temp Table?
Q62. What is Derived Table or DT in SQL? How DT is different from Common Table Expression (CTE) in SQL?
Q63. What is Common Table Expression or CTE in SQL?
Q64. What is Table Variable? What is the difference between Table Variable and Temp Table in SQL?
Q65. What is Table-Valued Type? What is the difference between Table Variable and Table-Valued Type in SQL?
Q66. What is the difference between PIVOT and UNPIVOT Functions in SQL?
Q67. What is the CASE statement in SQL? Can you use the CASE statement in the WHERE clause?






Part 09https://www.techpointfunda.com/2022/07/sql-interview-part-09.html


Q68. What is JOIN in SQL? What are the different types of join available in SQL?
Q69. What is INNER JOIN in SQL?
Q70. What is Self JOIN in SQL? How it is different from INNER JOIN?
Q71. What is LEFT JOIN in SQL? What is the difference between LEFT JOIN vs INNER JOIN?
Q72. What is RIGHT JOIN? What is the difference between RIGHT JOIN and LEFT JOIN in SQL?
Q73. What is FULL JOIN in SQL?
Q74. What is CROSS JOIN in SQL? What is the use of Cross Join?
Q75. What is the difference between FULL JOIN vs CROSS JOIN in SQL?
Q76. What is the difference between ON Clause vs WHERE clause in SQL?
Q77. What is the difference between INNER JOIN vs IN() clause?
Q78. What is the difference between JOIN and UNION in SQL?






Part 10https://www.techpointfunda.com/2022/07/sql-interview-part-10.html


Q79. How can you get the 3rd highest salary in SQL?
Q80. How can you delete the duplicate records from a table? 
Q83. How can you create a table from another table without using CREATE command?
Q84. How can you clone the table with schema and data?
Q85. How can you insert data from a table into another table without any loop or cursor?
Q88. How can you get the last inserted record id in SQL?
Q89. How can you update the gender column of the table to 'M' if 1, 'F' if 2, and 'U' if NULL?






Part 11https://www.techpointfunda.com/2022/08/sql-interview-part-11.html


Q90. What is the stored procedure? What are the features of a stored procedure?
Q91. While you creating stored procedures you have seen some SET Options like ANSI_NULLS, NOCOUNT, QUOTED IDENTIFIER, etc. What is the purpose of these SET Options in SP?
Q92. What do you understand by the fully qualified name (three-part identifiers) of the stored procedure? When the fully qualified SP name is required?
Q93. What are the advantages and disadvantages of using stored procedures?
Q94. How can you manage the stored procedure? Can you tell me some metadata objects which are used to view and manage the SP?
Q95. What are different types of stored procedures?
Q96. Why the "sp_ " prefix should be avoided while creating a user-defined Stored Procedure?
Q97. What is Parametrized Stored Procedure? What are the different ways to pass parameters in stored procedures? 
Q98. What is the OUTPUT parameter in the stored procedure? Can the OUT parameter be defined as Default as well? 
Q99. What is the Default Parameter in the stored procedure?







Part 12https://www.techpointfunda.com/2022/08/sql-interview-part-12.html


Q100. How can you return value from a stored procedure?
Q101. What is a temporary stored procedure? What is the use of a temp stored procedure?
Q102. What is the difference between recursive vs nested stored procedures? 
Q103. What is the use of the WITH RECOMPILE option in the stored procedure? Why one should use it?
Q104. How can you ENCRYPT and DECRYPT the stored procedure? 
Q105. How can you improve the performance of a stored procedure?
Q106. What is SCHEMABINDING in stored procedure? If all the stored procedures are bounded to the schema by default, then why do we need to do it explicitly?
Q107. How can you write a stored procedure which executes automatically when SQL Server restarts?
Q108. Is stored procedure names case-sensitive?
Q109. What is CLR stored procedure? What is the use of the CLR procedure?
Q110. What is the use of  EXECUTE AS clause in the stored procedure?  







Part 13: https://www.techpointfunda.com/2022/08/sql-interview-part-13.html


Q111. What is SQL Function? What are the different types of functions in SQL?
Q112. What is the difference between Deterministic vs Non-Deterministic SQL Functions?
Q113. What are the different System SQL Functions?
Q114. What is User Defined Function (UDF) in SQL? What is the advantage of UDF in SQL?
Q115. What are the features and limitations of User-Defined SQL Functions (UDF)?
Q116. What are the different Scalar User-Defined SQL Functions?
Q117. What are the different Table-Valued UDF in SQL?
Q118. What is Schema Bound function in SQL? What is the advantage of schema-bound functions?
Q119. What is the difference between Stored Procedure and User-Defined Function in SQL?
Q120. What is the difference between Table-Valued Functions and View in SQL? 







Part 14: https://www.techpointfunda.com/2022/04/sql-interview-part-14.html


Q100. How can you return value from a stored procedure?
Q121. What is View in SQL? 
Q122. What are the Advantages and Disadvantages of view?
Q123. What are the different types of views in SQL?
Q124. What is Schema Bounded View? What are its advantages?
Q125. What is Indexed View or Materialized View in SQL?
Q126. What is a Partitioned View? What is its use in SQL?
Q127. Can you UPDATE or DELETE the records from View? What is the updatable view?
Q128. Can you add the Primary Key Constraint in the View? 
Q129. What is the difference between View and Table?
Q130. What is the difference between View and Temp Table?









Q131. What is a Trigger in SQL? 
Q132. What are the Advantages and Disadvantages of Triggers in SQL?
Q133. What are the different types of Triggers available in SQL?
Q134. What is DML Trigger in SQL? What is the application of DML Triggers?
Q135. What is AFTER or FOR TRIGGER in SQL? What is the use of AFTER DML Trigger?
Q136. What is INSTEAD OF TRIGGER in SQL? How can you use the INSTEAD OF Trigger to update the VIEW?
Q137. What is DDL TRIGGER in SQL? What is the application of  DDL Triggers?
Q138. What is LOGON TRIGGER in SQL? What is the application of  LOGON Triggers?
Q139. What is the difference between Recursive Trigger and Nested Trigger in SQL?
Q140. What are the MAGIC TABLES in SQL? What is the use of INSERTED and DELETED tables in SQL?







Part 16: https://www.techpointfunda.com/2022/09/sql-interview-part-16.html


Q141. What is the Cursor in SQL? 
Q142. What is the Cursor Life Cycle in SQL? 
Q143. What are the different types of Cursors in SQL? 
Q144. What is the Static Cursor or InSensitive Cursor in SQL? 
Q145. What is the Dynamic Cursor in SQL? 
Q146. What is the Forward Only Cursor or Firehouse Cursor in SQL? What is the difference between Forward-Only and Fast Forward Cursor?
Q147. What is the KeySet Cursor in SQL? 
Q148. What are the advantages and applications of Cursors in SQL?
Q149. What are the disadvantages or limitations of Cursors in SQL? 
Q150. What is the difference between Loop and Cursor?
Q151. How you can avoid the cursor in SQL? What are the different alternatives of Cursor in SQL?







Part 17: https://www.techpointfunda.com/2022/09/sql-interview-part-17.html


Q152. What is a Transaction in SQL?
Q153. What is TCL in SQL? What are the different TCL commands?
Q154. What are ACID properties in SQL?
Q155. What is the use of SAVEPOINT in Transaction?
Q156. What is the difference between COMMIT and SAVE transactions in SQL?
Q157.  What is the use of @@TRANCOUNT in SQL?
Q158. What is the difference between TRANSACTION and DISTRIBUTED TRANSACTION in SQL?
Q159. What is a Two-Phase Commit (2PC) in SQL?  Why it is required?
Q160. What is the SET XACT_ABORT  option in SQL? How does it affect the transaction?






Part 18: https://www.techpointfunda.com/2022/09/sql-interview-part-18.html


Q161. What is Concurrency in SQL? What are the different concurrency problems in SQL?
Q162. What is a Dirty Read Problem in SQL? How can you avoid this Dirty Read Problem?
Q163. What is a Phantom Read Problem in SQL? How can you avoid this Phantom Read Problem?
Q164. What is a Non-Repeatable Read Problem in SQL? How can you avoid this Non-Repeatable Read Problem of SQL?
Q165. What is a Lost Update Problem in SQL? How can you avoid this Lost Update Problem of SQL?
Q166. How can you solve the Concurrency Problems in SQL? What are the different Concurrency Control Mechanisms available in SQL? 
Q167. What is Transaction Isolation? What are the different Transaction Isolation Levels in SQL?
Q168. What is the difference between the Read Committed and Read Uncommitted Isolation Levels in SQL?
Q169. What is the Repeatable Read Isolation Level in SQL?
Q170. What is the difference between Serializable and Snapshot Isolation Levels in SQL?







Part 19: https://www.techpointfunda.com/2022/09/sql-interview-part-19.html


Q171. What is LOCK in SQL? Why locking is important in SQL if it causes performance overheads?
Q172. What is the Locking Hierarchy in SQL? What are the different resources that can have a lock?
Q173. What are the different types of lock modes in SQL?
Q174. What is Shared Lock (S) in SQL?
Q175. What is Exclusive Lock (X) in SQL?
Q176. What is Update Lock (U) in SQL?
Q177. What is Intent Lock (I) in SQL? What are the different types of Intent Lock?
Q178. What is Schema Lock (Sch) in SQL?
Q179. What is Bulk Update Lock (BU) in SQL?
Q180. What is the Key Range Lock in SQL?











Q181. What is SQL Lock Compatibility? Can a resource have multiple locks at the same time?
Q182. What is Lock Escalation in SQL?
Q183. What is Dynamic Locking in SQL?
Q184. What is SQL Table Hint? 
Q185. What is the difference between NOLOCK, and NOWAIT Table Hint in SQL?
Q186. What is the difference between READPAST and READUNCOMMITED Table Hint?
Q187. What is the difference between IGNORE_CONSTRAINTS and IGNORE_TRIGGERS table hint?
Q188. What is the use of INDEX Table Hint? What is the difference between INDEX(0) and INDEX(1) hint?
Q189. What is the difference between FORCESEEK vs FORCESCAN Table Hint?
Q190. How can you check the occupied locks on a table or database?








Q191. What is a deadlock in SQL? What is the difference between Deadlocking vs Blocking?
Q192. How can you detect and prevent deadlock in SQL?
Q193. What are the different tools that can be used to detect the deadlock? 
Q194. If there is a table that is causing a deadlock most frequently. How can you minimize the deadlock on that table?
Q195. What is Nested Transaction in SQL?
Q196. What is the use of the @@ROWCOUNT function in SQL?
Q197. What is Distributed Transaction in SQL?
Q198. Does Temp Table support TCL Commands?  Can you use a Temp Table in Transaction?
Q199. Does Table Variable support TCL Commands?  Can you use a Table Variable in Transaction?
Q200. Does Table-Valued Type support TCL Commands?  Can you use a Table-Valued Type in Transaction?










Q201. How can you Handle Exceptions in SQL? Can you use the TRY/CATCH in SQL?
Q202. What is the TRY-CATCH Exception Handling Mechanism in SQL?
Q203. What is the @@ERROR function in SQL?
Q204. What is ERROR_MESSAGE() function in SQL?
Q205. What is the use of the RAISERROR () function in SQL?
Q206. What is the use of the THROW Statement in SQL?
Q207. What is the difference between the RAISERROR function and the THROW statement?
Q208. What are the Predefined Errors and their formats in SQL?
Q209. How can you generate user-defined custom error messages in SQL? 
Q210. What is the Error Severity in SQL? What is its use?











Q211. What is Dynamic SQL Query(D-SQL) in SQL? How it is different from Static SQL Query?
Q212. How can you run the Dynamic SQL Query? What is the difference between EXECUTE(), and sp_executesql() in SQL?
Q213. Can you use Dynamic SQL Query in Functions? Why?
Q214. Can you use the OUT parameter in a Dynamic SQL Query? 
Q215. Can you return a value from the Dynamic SQL Query?
Q216. Can you use Temp Table in Dynamic SQL Query?
Q217. Can you use Transaction in Dynamic SQL Query?
Q218. What is the QUOTENAME() function in SQL?
Q219. What is SQL Injection? How can you prevent SQL Injection attacks?
Q220. Can you give me some Real Use Cases of Dynamic SQL Queries?










Q221. What is an IDENTITY in SQL?
Q222. What is the use of the @@IDENTITY function in SQL?
Q223. What is the use of the DBCC CHECKIDENT command?
Q224. What is Sequence in SQL?
Q225. What is the difference between an IDENTITY Column and a Sequence Object in SQL?
Q226. What is the use of the OUTPUT INTO clause in SQL?
Q227. What is a wildcard character in SQL? What is the use of the LIKE keyword in SQL?
Q228. What is SQL Data Type in SQL? How a scaler values type is different from a table-valued type?
Q229. How can you do Bulk Copy in SQL? What is the SQL BulkCopy? 
Q230. What are the different types of backup in SQL?













Recommended Articles






Thanks for visiting this page. Please follow and join us on LinkedInFacebookTelegramQuoraYouTubeTwitterPinterestTumbler, and VK  for regular updates.

    

No comments:

Post a Comment

Please do not enter any HTML. JavaScript or spam link in the comment box.