SQL Server Interview Questions

Ques 1. What is SQL ?

Ans. Structured Query Language(SQL) is a language designed specifically for communicating with databases. SQL is an ANSI (American National Standards Institute) standard.

Ques 2. What are the different type of SQL's statements ?

Ans. 1. DDL – Data Definition Language DDL is used to define the structure that holds the data. For example, Create, Alter, Drop and Truncate table. 2. DML– Data Manipulation Language DML is used for manipulation of the data itself. Typical operations are Insert, Delete, Update and retrieving the data from the table. Select statement is considered as a limited version of DML, since it can't change data in the database. But it can perform operations on data retrieved from DBMS, before the results are returned to the calling function. 3. DCL– Data Control Language DCL is used to control the visibility of data like granting database access and set privileges to create tables etc. Example - Grant, Revoke access permission to the user to access data in database.

Ques 3. What are the Advantages of SQL?

Ans. 1. SQL is not a proprietary language used by specific database vendors. Almost every major DBMS supports SQL, so learning this one language will enable programmers to interact with any database like ORACLE, SQL ,MYSQL etc. 2. SQL is easy to learn. The statements are all made up of descriptive English words, and there aren't that many of them. 3. SQL is actually a very powerful language and by using its language elements you can perform very complex and sophisticated database operations.

Ques 4. what is a field in a database ?

Ans. A field is an area within a record reserved for a specific piece of data. Examples: Employee Name, Employee ID etc

Ques 5. What is a primary key?

Ans. A primary key is a column whose values uniquely identify every row in a table. Primary key values can never be reused. If a row is deleted from the table, its primary key may not be assigned to any new rows in the future. To define a field as primary key, following conditions had to be met : 1. No two rows can have the same primary key value. 2. Every row must have a primary key value 3. The primary key field cannot be null 4. Values in primary key columns can never be modified or updated

Ques 6. What is a Composite Primary Key ?

Ans. A Composite primary key is a set of columns whose values uniquely identify every row in a table. What it means is that, a table which contains composite primary key will be indexed based on the columns specified in the primary key. This key will be referred in Foreign Key tables. For example - if the combined effect of columns, "Employee_ID" and "Employee Name" in a table is required to uniquely identify a row, its called a Composite Primary Key. In this case, both the columns will be represented as primary key.

Ques 7. What is a Foreign Key ?

Ans. When a "one" table's primary key field is added to a related "many" table in order to create the common field which relates the two tables, it is called a foreign key in the "many" table. For example, the salary of an employee is stored in salary table. The relation is established via foreign key column “Employee_ID_Ref” which refers “Employee_ID” field in the Employee table.

Ques 8. What is a Unique Key ?

Ans. Unique key is same as primary with the difference being the existence of null. Unique key field allows one value as NULL value.

Ques 9. Define SQL Insert Statement ?

Ans. SQL INSERT statement is used to add rows to a table. For a full row insert, SQL Query should start with “insert into “ statement followed by table name and values command, followed by the values that need to be inserted into the table. The insert can be used in several ways: 1. To insert a single complete row. 2. To insert a single partial row.

Ques 10. Define SQL Update Statement ?

Ans. SQL Update is used to update data in a row or set of rows specified in the filter condition. The basic format of an SQL UPDATE statement is, Update command followed by table to be updated and SET command followed by column names and their new values followed by filter condition that determines which rows should be updated.

Post Question Details

Ques. hello

Posted On:8/18/2023 10:48:36 PM

Ques. What is Profiler?

Posted On:2/19/2021 9:38:36 PM

Ques. b bm n,

Posted On:3/4/2020 11:20:48 PM