Skip to content
Home » SQL Interview Q & A

SQL Interview Q & A

A series of SQL Server basics to advanced level of Interview questions and answers which are commonly asked in interview.




SQL Server QUIZ

  1. SQL Quiz on Substring function
  2. SQL QUIZ on Select Statement
  3. SQL Quiz on Create Statement

[ Also Read: SQL Server Basics Tutorial]

LeetCode – SQL Interview Questions
LeetCode – Rank Scores 

LeetCode – Nth Highest Salary

HackerRank – SQL Interview Questions

HackerRank SQL Interview Question- Occupations

SQL Server Interview Questions and Answers

  1. Difference between Primary Key and Composite Key?
  2. SQL DDL, DML, DCL and TCL commands?
  3. Difference between Stored Procedure and Functions?
  4. Difference between Truncate and Delete statements in SQL Server?
  5. What is Views in SQL Server?
  6. How to get the definitions of stored procedures, user defined functions and triggers in SQL ?
  7. SQL CROSS APPLY vs OUTER APPLY, and how do they differ from Joins?
  8. How to check if user table or temp table exists or not in SQL Server database?
  9. How to display a cumulative Total/ Running Total in SQL?
  10. What is correlated subquery in SQL?
  11. Difference between NULL and BLANK in SQL Server?
  12. What is SQL Server user defined table type and table valued parameters?
  13. How to access the files name list from window directory folder to SQL Server table using T-SQL query?
  14. How to access a data of table from another database in SQL Server?
  15. How to implement a custom sorting in SQL Server?
  16. What is Sequence in SQL?
  17. What is foreign key in SQL server and how to add a foreign key in existing table?
  18. What is SQL drop table command, does it support rollback ?
  19. What is unique key constraint in SQL Server ?
  20. What is TRY..CATCH block and how to handle T- SQL code error using TRY.. CATCH block?
  21. How to Pivot a table in SQL?
  22. How to Unpivot a table data in SQL?
  23. What is triggers in SQL ?
  24. What is Merge Statement in SQL and use of Merge in SQL ?
  25. How to create Jobs in SQL Server ?
  26. What is SQL Server temporary tables?
  27. What is GROUPING SETS in SQL?
  28. What is CUBE in SQL ?
  29. What is IIF() Logical Function is SQL ?
  30. What is Choose() logical function in SQL?
  31. How to identify blocking processes/long running queries in SQL server ?
  32. What is SQL Server Computed Columns ?
  33. How to find out identity column without using column name ?
  34. How to configure SQL Server Database Mail ?
  35. How to troubleshoot SQL Server Database Mail?
  36. What is synonyms in SQL Server and its role ?
  37. How to insert explicit values into identity column ?
  38. How to send a SQL Server Query result in text format using database e-mail?
  39. What is NEWSEQUENTIALID() function in SQL Server, what is the difference between NEWSEQUENTIALID() and NEWID() ?
  40. How to get the sizes of all databases on a SQL Server ?
  41. How to display currency symbol for different different cultures in SQL Server?
  42. How to concatenate rows of strings into one string with a specified separator?
  43. How to find Nth highest salary in SQL Server ?
  44. How to display detailed truncation error in SQL Server ?
  45. How to Split Comma Separated string values into columns? 
  46. How to Display calendar dates for any n numbers of years in SQL Server?
  47. Difference between VARCHAR VS NVARCHAR?
  48. Difference between CHAR VS NCHAR?
  49. What is the difference between SQL Server Stored Procedures and User Defined Functions (UDF)?
  50. FOR JSON clause in SQL Server?
  51. What is LogOn trigger in SQL Server?
  52. How to get all the tables in database those contains primary key constraints ?
  53. How to create a dynamic column in pivot ?
  54. Write SQL query to get the students who have scored higher than 80 marks and sort result based on last three characters of name and StudID in ascending order ?
  55. Print prime number separated by comma till n numbers in SQL?
  56. What is cascading referential integrity in SQL Server?
  57. How to get the last accessed time for tables in SQL Server?
  58. How to copy or delete files from directory in SQL Server?
  59. How to change the column collation to case sensitive?
  60. How to auto execute any stored procedure on SQL Server Services startup ?
  61. How to encrypt a stored procedure in SQL Server?
  62. How to Read SQL Server error logs?
  63. How to extract a Scalar value from JSON string?
  64. How to extract a Json object and Json array from JSON string?
  65. How to modify property and it’s value in JSON string?
  66. How to separate numbers, letters and special characters from string?
  67. What is SQL Ident_current function and how it differ from @@Identity and Scope_Identity?
  68. How to select top n records for each category from table?
  69. How to change the column name and their data type of result set of stored procedure?
  70. What is Table Value Constructor?
  71. How to generate a scripts for database with schema and data?
  72. How to script a table in SQL Server?
  73. How to check if column exists or not in SQL Server table?
  74. How to get row count for all tables in SQL Server ?
  75. Date and Time Conversions in SQL Server using Convert function.
  76. How to store the output of stored procedure into a table/temp table?
  77. How to insert a multi language/multilingual data in table?
  78. How to Update records from select statement in SQL?
  79. Difference between Clustered and Non-Clustered indexes in SQL Server ?
  80. How to fetch an alphanumeric from string?
  81. How to generate a range of numbers between two numbers in SQL Server?
  82. How to search for string within xml column in SQL table?
  83. How to find leading and trailing spaces in SQL Server ?
  84. How to compare column names in two tables in SQL Server ?
  85. How to Insert same row multiple times in a table in SQL Server?
  86. How to get the size of all tables in SQL Server?
  87. How to get top Nth highest salary in each department?
  88. How to calculate rolling average?
  89. How to get multiple row data in single row in SQL?
  90. How to reset identity column value in table?
  91. Display employees and their reporting manager name in SQL?
  92. Difference between UNION and UNION ALL?
  93. Find a managers with at least 3 direct reports.
  94. Find a largest single number in a table.
  95. Find department top 3 salaries.

[Also Read.. SSRS Tutorial,  SQL Server Advance Tutorial,  Power BI Tutorial ]




SQL Server Basics Tutorial

SSRS Tutorial

SQL Server Advance Tutorial

Power BI Tutorial

Loading