SQL Tricky Questions
SQL Tricky Questions
Inner Join
Outer Join (Left Outer Join and Right Outer Join)
Cross join
Self-Join
3)
What is an Index?
There are two types of indexes. Clustered index and Non Clustered Index. A
table can have only 1 Clustered Index while it can have up to 249 & 999
nonclustered indexes on SQL Server 2005 & 2008 respectively. A clustered
index stores the actual data rows at the leaf level of the index. Indexes can
make Select statement fast but delete, update and insert statements will get
slow.
4)
a)
READ UNCOMMITTED
b)
READ COMMITTED
c)
REPEATABLE READ
d)
SERIALIZABLE
e)
SNAPSHOT
5)
Example:
WHERE publishers.state = CA
GROUP BY titles.pub_id
HAVING AVG(titles.price) > 10
WHERE clause is applied first to the individual rows in the tables . Only the
rows that meet the conditions in the WHERE clause are grouped. The HAVING
clause is then applied to the rows in the result set.
7)
b) Data Error: is handled in DATA FLOW TASK buy redirecting the data flow
using Error Output of a component.
8)
Both primary key and unique enforce uniqueness of the column on which
they are defined. But by default primary key creates a clustered index on the
column. Major difference is that, primary key does not allow NULLs, but
unique key allows NULL.
9)
What are defaults? Is there a column to which a default cannot be
bound?
Example: