Sources:
- http://www.mssqltips.com/sql-server-tip-category/139/interview-questions-developer/
- top-50-datawarehousing-questions-answers.pdf
Important questions and links:
- Difference between all three identity functions( @@identity, SCOPE_IDENTITY() and IDENT_CURRENT() ): http://www.mssqltips.com/sqlservertip/1385/properly-capturing-identity-values-in-a-sql-server-database/
- Difference between CHECKSUM and BINARY_CHECKSUM: http://decipherinfosys.wordpress.com/2007/05/18/checksum-functions-in-sql-server-2005/
- GROUPING SET(): http://sqlandme.com/2011/07/12/sql-server-tsql-group-by-grouping-sets/
- CDC: https://www.simple-talk.com/sql/learn-sql-server/introduction-to-change-data-capture-(cdc)-in-sql-server-2008/
- Indexing: http://www.mssqltips.com/sqlservertip/1206/understanding-sql-server-indexing/
- Difference between Unique Clustered Index and Clustered Index (non-unique): http://dba.stackexchange.com/questions/55654/difference-between-clustered-index-and-unique-clustered-index
- Comma separated: http://davidduffett.net/post/5334646215/get-a-comma-separated-list-of-values-in-sql-with-for
- nth salary: http://sqlfiddle.com/#!6/c486e/1/0
- For XML: https://www.simple-talk.com/sql/learn-sql-server/using-the-for-xml-clause-to-return-query-results-as-xml/ Fiddle: http://sqlfiddle.com/#!6/ebf7c/15
- Pivot n Unpivot: http://sqlhints.com/2014/03/10/pivot-and-unpivot-in-sql-server/
- No duplicates: http://www.mssqltips.com/sqlservertip/1103/delete-duplicate-rows-with-no-primary-key-on-a-sql-server-table/
TSQL Questions:
- Finding Grand parent in a parent-child table (http://sqlfiddle.com/#!6/24c7b/6)
- There are three projects and each have its table. Table have information of employee ids and hours of work they have done in that project. Print list of all employees and total hours they have worked across all projects. (Full Outer Join with Coalesce)
- Implementation of SCD – 2 (Pull data from sources, make a dimension which has 4 of its columns trended)
- Output for a query that contains a self-joined table on condition A.ID = B.ID – 1 and select has subtraction of fact
- Many to many relationship (keep mapping table)
- Left Join and WHERE clause (which works as EXCEPT
SQL Hacks: http://sqlzoo.net/wiki/Running_Total
SQL Hacks book: (Download it from 4shared.com)
Important hacks:
- 3
- 10 (Without the subquery, the optimizer finds it much easier to use your indexes)
- 11
- 23
- 24 (Multiply across result set) (Exp, SUM, Log)
- 25
- 27 (Join on equality condition and OR)
- 31
- 51
- 52
- 56
- 75
- 78
- 80
- 81
- 82
- 84
- 85
- 88