SQL Server Interview Questions and Answers – Part 1

SQL Server Interview Questions and Answers
Print Book Available (207 Pages) | Sample Chapters

UPDATE : Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. New Location : SQL Server 2008 Interview Questions and Answers.

What is RDBMS?
Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.

What is normalization?
Database normalization is a data design and organization process applied to data structures based on rules that help build relational databases. In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.

What are different normalization forms?

1NF: Eliminate Repeating Groups
Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.
2NF: Eliminate Redundant Data
If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NF: Eliminate Columns Not Dependent On Key
If attributes do not contribute to a description of the key, remove them to a separate table.
All attributes must be directly dependent on the primary key
BCNF: Boyce-Codd Normal Form
If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.
4NF: Isolate Independent Multiple Relationships
No table may contain two or more 1:n or n:m relationships that are not directly related.
5NF: Isolate Semantically Related Multiple Relationships
There may be practical constrains on information that justify separating logically related many-to-many relationships.
ONF: Optimal Normal Form
A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.
DKNF: Domain-Key Normal Form
A model free from all modification anomalies.

Remember, these normalization guidelines are cumulative. For a database to be in 3NF, it must first fulfill all the criteria of a 2NF and 1NF database.

What is Stored Procedure?
A stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve performance. Stored procedures can be used to help ensure the integrity of the database.
e.g. sp_helpdb, sp_renamedb, sp_depends etc.

What is Trigger?
A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE) occurs. Triggers are stored in and managed by the DBMS.Triggers are used to maintain the referential integrity of data by changing the data in a systematic fashion. A trigger cannot be called or executed; the DBMS automatically fires the trigger as a result of a data modification to the associated table. Triggers can be viewed as similar to stored procedures in that both consist of procedural logic that is stored at the database level. Stored procedures, however, are not event-drive and are not attached to a specific table as triggers are. Stored procedures are explicitly executed by invoking a CALL to the procedure while triggers are implicitly executed. In addition, triggers can also execute stored procedures.
Nested Trigger: A trigger can also contain INSERT, UPDATE and DELETE logic within itself, so when the trigger is fired because of data modification it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger.

What is View?
A simple view can be thought of as a subset of a table. It can be used for retrieving data, as well as updating or deleting rows. Rows updated or deleted in the view are updated or deleted in the table the view was created with. It should also be noted that as data in the original table changes, so does data in the view, as views are the way to look at part of the original table. The results of using a view are not permanently stored in the database. The data accessed through a view is actually constructed using standard T-SQL select command and can come from one to many different base tables or even other views.

What is Index?
An index is a physical structure containing pointers to the data. Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes, they are just used to speed up queries. Effective indexes are one of the best ways to improve performance in a database application. A table scan happens when there is no index available to help a query. In a table scan SQL Server examines every row in the table to satisfy the query results. Table scans are sometimes unavoidable, but on large tables, scans have a terrific impact on performance.

Clustered indexes define the physical sorting of a database table’s rows in the storage media. For this reason, each database table may have only one clustered index.
Non-clustered indexes are created outside of the database table and contain a sorted list of references to the table itself.

Complete Series of SQL Server Interview Questions and Answers
SQL Server Interview Questions and Answers -Introduction
SQL Server Interview Questions and Answers – Part 1
SQL Server Interview Questions and Answers – Part 2
SQL Server Interview Questions and Answers – Part 3
SQL Server Interview Questions and Answers – Part 4
SQL Server Interview Questions and Answers – Part 5
SQL Server Interview Questions and Answers – Part 6
SQL Server Interview Questions and Answers Complete List Download

Reference : Pinal Dave (http://blog.SQLAuthority.com)

About these ads

76 thoughts on “SQL Server Interview Questions and Answers – Part 1

  1. Its AWESOME , and your rocking with SQLSERVER. keep it up and try to increase the content and more readble.

  2. Its really nice.This will help me to get a job.Please send some interview tips for sql sever2005 also.
    Jinu

  3. SIR,

    it is really awesome. you are great. you are doing a good job for coming generation.

    my salute for you.

    thanking you & best regards

    kumar

  4. Appriciated !! but i guess all depends on level which you going for ,for beginners its really usefull !!

    cheers

  5. Pingback: SQL SERVER - Data Warehousing Interview Questions and Answers - Part 2 Journey to SQL Authority with Pinal Dave

  6. hello sir

    now your doing the better and good job …..its very nice for our future generation…pls update new type of questions……….

  7. I READ TO QUESTION THAT IS AMAZING.
    THIS IS GREAT HELP …….
    TRULY APPRECIATED.

    IT IS REALLY AWESOME YOUARE GREAT. YOU AREDOING A GOOD JOB FOR COMING GENERATION.

    THINGING YOU & BEST REHARDS

  8. Hey Steve,

    You can modify the data through view.
    There are a few things you should consider….. using instead of triggers or using updatable partitioned views.
    If none of these are used then there are few thing you should consider……
    one cannot use data modification statements on more than one underlying table in a single statement and also while updating one should make sure about the column restrictions (constraints, nullability…..)
    Hope this helps you.

  9. hi friend,
    i m new for this site,and i feel that it is one of the best site for getting the information regarding the sql and other one for interview purpose and for knowledge enhancement.

  10. hi

    mr.dave

    its really good.

    try to put the details about the DTS and Linked Servers
    concepts with examples. That will me more useful for all.

    Thanking u for providing these Questions with Answers.

    regards

    vijay raju

  11. Dear sir,

    My heartfull thanks to u,this is really good,your helping me more………….I Think this one is helpfull for everyone..

    Thanksalot,
    Swapna

  12. Hello

    Can you tell me please the function to split a name received in one field to first name, last name, middle name into separate fields?

    Thanks very much!

  13. hi

    This is very useful for my interview preparation.If you know any new concepts.please post my email id.

    Thanking you

  14. You are awesome.. I appreciate the amount of time you spend towards this blog which is so useful for many people like me. Keep up the good work! God Bless You ..

  15. Hi Pinal Dave…

    I am Proud of you….
    you are doing a very great Job…
    All the Best for Your Future….

    JAI HIND…
    (Sabse aage Honge….Hindustani !!!!!!)

  16. hi

    This is very useful for my interview preparation.If you know any new concepts.please post my email id.
    Plz, send me sql server database notes.
    Thanking you

  17. Hello! Sir,

    Good evening.

    I am thankful to you for this useful information, which helps me and to everybody…

    Sure, u have important role in everybody’s success…

    Thank you very much.
    All the Best.

    Shrinivas

  18. Hi,

    This is awesome and really very useful those who preparing for their interview..

    Thank you very much,
    Jayaprabha.D

  19. Dear Sir,

    Mostly I used name only, but now I used Sir.

    I will pray for you to give more years to live in the same.

    Thanks,
    JSaraboji.

  20. Excellent! The question and answers are great. I am looking for a job and It really helps me to prepare me for the Interview.

    Thanks! Please keep updating this site.

  21. Hii,

    Really liked it. Want a copy of all the qs and ans.
    Can u plz send it at my mail id.

    Thanx.

  22. Um, I’m not sure this was meant to help people who know diddly to get jobs as senior DBAs, I think the idea was to put together some common questions one might want to ask candidates in an interview.

    But I could be wrong.

  23. Dave,
    This is an excellent effort, these questions are not only useful in an interview prespective but will also provide a definite insight of SQL for beginners. Hope to have much more questions like this in the future.

    Cheers,
    Chendu

  24. Respected sir

    your question is very brilliant . please send the other interview aptitude question for c and c++

  25. I Have Seen all the Question and Answer its Really Good Stuff but when the Candiadte Have experince then interviewer mostly asked about the Query Basically that stuff is only for the Fresher or 1 years Experience Candiate

    Thahx
    Irshad hasan

  26. Hello Pinal,

    Nice questions. In fact i am interviewing people thru these Qs. These are really awesome. I am done with MCSD & a .net developer since 3.5years. I am so interested for SQL DBA. Please guide me how to process.

    Waiting your reply.

    Regards
    ~ Riti

  27. hi dave,

    you are doing nice job,
    This is an excellent effort, these questions are not only useful in an interview prespective but will also provide a definite insight of SQL for beginners

  28. Pingback: SQL SERVER - Database Interview Questions and Answers Complete List Journey to SQL Authority with Pinal Dave

  29. Pingback: SQL SERVER – Weekly Series – Memory Lane – #025 | SQL Server Journey with SQL Authority

Comments are closed.