60 SQL Interview Questions and Answers
60 SQL Interview Questions and Answers
41. Explain the difference between INNER JOIN and OUTER JOIN.
Answer: INNER JOIN returns rows when there is at least one match in both tables.
OUTER JOIN returns all rows from one table and matched rows from the other.
42. What is a full-text search in SQL?
Answer: Full-text search in SQL is a feature for performing complex queries
against character-based data.
43. Explain the use of the EXCEPT clause.
Answer: EXCEPT returns all rows from the first dataset that do not exist in the
second dataset.
44. What is a window function in SQL?
Answer: Window functions perform a calculation across a set of table rows that are
somehow related to the current row.
45. What does a cross-apply in SQL?
Answer: CROSS APPLY is used to join a table to a table-valued function.
46. What is SQL injection and how can it be prevented?
Answer: SQL injection is a code injection technique where attackers can execute
malicious SQL. It can be prevented by using parameterized queries.
47. What is the difference between a function and a stored procedure?
Answer: A function must return a value and cannot modify the data received as
parameters, while a stored procedure doesn't have to return a value and can modify
data.
48. What is a temporary table in SQL?
Answer: Temporary tables are used to store temporary data. They are created in the
database for the duration of a session.
49. What is the use of the COALESCE function?
Answer: COALESCE returns the first non-null value in a list.
Thank you!