SQL Server - Common Interview Questions and Answers
What is BCP? When does it used?
BulkCopy is a tool used to copy huge amount of data from tables and views. BCP does not
copy the structures same as source to destination. BULK INSERT command helps to import a
data file into a database table or view in a user-specified format.
How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?
One-to-One relationship can be implemented as a single table and rarely as two tables with
primary and foreign key relationships. One-to-Many relationships are implemented by
splitting the data into two tables with primary key and foreign key relationships.
Many-to-Many relationships are implemented using a junction table with the keys from
both the tables forming the composite primary key of the junction table.
What is an execution plan? When would you use it? How would you view the execution plan?
An execution plan is basically a road map that graphically or textually shows the data
retrieval methods chosen by the SQL Server query optimizer for a stored procedure or ad-
hoc query and is a very useful tool for a developer to understand the performance
characteristics of a query or stored procedure since the plan is the one that SQL Server will
place in its cache and use to execute the stored procedure or query. From within Query
Analyzer is an option called "Show Execution Plan" (located on the Query drop-down
menu). If this option is turned on it will display query execution plan in separate window
when query is ran again.