Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
194 views

SQL Server Interview Questions - Basic SQL Server Interview Questions

This document contains basic SQL Server interview questions and answers. It discusses SQL statements like DML, DDL, DCL and TCL with examples. It also explains the differences between Drop, Delete and Truncate statements. Additionally, it defines cascading referential integrity constraints and the differences between primary keys and unique keys in SQL Server.

Uploaded by

parashuram n
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views

SQL Server Interview Questions - Basic SQL Server Interview Questions

This document contains basic SQL Server interview questions and answers. It discusses SQL statements like DML, DDL, DCL and TCL with examples. It also explains the differences between Drop, Delete and Truncate statements. Additionally, it defines cascading referential integrity constraints and the differences between primary keys and unique keys in SQL Server.

Uploaded by

parashuram n
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions

22   More    Next Blog» Create Blog   Sign In

SQL Server Interview Questions
C#
Boo MV ASP. C SQL W Written HR Subsc SQL Buy
Program 22
ks C NET # Server CF Test Round ribe Tutorial DVD
s

If you like this website, please share


this site using g+1 button Basic SQL Server Interview Questions
+22   Recommend this on Google

Best software training institute in bangalore for SAP ABAP,
SAP BI, .Net, Informatica, Software Testing, Siebel CRM
I am Venkat and this is my website. I did training in Pragim
Technologies and got job in Dell in less than a week. PRAGIM is the
best S/W training institute in Bangalore.
Click here for Hyderabad Center Website
For further details please call 09900113931. *T&C

Explain DML, DDL, DCL and TCL statements with examples?
DML: DML stands for Data Manipulation Language. DML is used to retrieve,
store, modify, delete, insert and update data in database.
Examples of DML statements: SELECT, UPDATE, INSERT, DELETE
statements.
 

DDL: DDL stands for Data Definition Language. DDL is used to create and
modify the structure of database objects.

Examples: CREATE, ALTER, DROP statements.
 

DCL: DCL stands for Data Control Language. DCL is used to create roles, grant
and revoke permissions, establish referential integrity etc.
Examples: GRANT, REVOKE statements
 
SAP BI Training in Bangalore
Best SAP BI Training institute in Bangalore, TCL: TCL stands for Transactional Control Language. TCL is used to manage
Marathahalli. Real time project based training transactions within a database.
provided by working software professionals Examples: COMMIT, ROLLBACK statements
having more than 10 years of experience.
Informatica Training in Bangalore
Informatica training in bangalore delivered by
a real time software expert having 10 years
of experience. 
Siebel CRM Training in Bangalore
Best software training institute for Siebel CRM
training in Marathahalli, Bangalore. 
Software testing training institute in
bangalore

http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions.html 1/9
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions

Software testing training on real time projects
and placements. 
MSBI Training Institute in Bangalore
Best MSBI Training in Bangalore by an
expert. MSBI training on real time projects
and placements. 
Basic SQL Server Interview Questions

SQL Server Interview Questions on


Temporary Tables

SQL Server Interview Questions on


Indexes ‐ Part 1

SQL Server Interview Questions on


Indexes ‐ Part 2 *T&C

What is the difference between


Having and Where clause What is the difference between Drop, Delete and Truncate statements in
SQL Server?
What is the difference between a Drop, Delete and Truncate ­ All operations can be rolled back. 
Temporary Table and a Table Variable  
All the statements (Delete, Truncate and Drop) are logged operations, but the
What is the use of COALESCE in SQL amount of information that is logged varies. Delete statement logs an entry in the
Server transaction log for each deleted row, where as Truncate Table logs only the
Page deallocations.Hence, truncate is a little faster than Delete.  
SQL Server Interview Questions on  
triggers You can have a where clause in Delete statement where as Truncate statement
cannot have a where clause. Truncate will delete all the rows in a Table, but the
Difference between User Defined structure of the table remains. Drop would delete all the rows including the
Function and Stored Procedure structure of the Table.
 
SQL Server Interview Questions on  
Views ‐ Part 1 Please refer to the screen shot below for the differences summary snapshot
between Drop, Delete and Truncate statements in SQL Server. 
SQL Server Interview Questions on
Views ‐ Part 2

Basic SQL Server Interview Questions


on Joins

Explain Inner Join with an example


 
Explain Left Outer Join with an  
example What is Cascading referential integrity constraint? 
Cascading referential integrity constraints allow you to define the actions
Explain Right Outer Join with an Microsoft SQL Server should take when a user attempts to delete or update a
example key to which an existing foreign keys point. 
 
Explain Full Outer Join with an You can instruct SQL Server to do the following: 
example  
1. No Action: This is the default behaviour. No Action specifies that if an
Explain Self Join with an example attempt is made to delete or update a row with a key referenced by foreign keys
in existing rows in other tables, an error is raised and the DELETE or UPDATE is
What is the difference between Index rolled back. 
Scan and Index Seek  
2. Cascade: Specifies that if an attempt is made to delete or update a row with a
Write a SQL Query to delete from a key referenced by foreign keys in existing rows in other tables, all rows
table that is involved in a SQL join containing those foreign keys are also deleted or updated. 
 
What are the advantages of using 3. Set NULL: Specifies that if an attempt is made to delete or update a row with
stored procedures a key referenced by foreign keys in existing rows in other tables, all rows
containing those foreign keys are set to NULL.   
What are the different ways to  
replace NULL values in SQL Server 4. Set Default: Specifies that if an attempt is made to delete or update a row
http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions.html 2/9
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions

with a key referenced by foreign keys in existing rows in other tables, all rows
SQL Server interview questions on containing those foreign keys are set to default values. 
string manipulation functions  
DIfference between primary key and unique key in SQL Server? 
Write a Stored Procedure that takes 1. A table can have only one primary key. On the other hand a table can have
column name as a parameter and more than one unique key. 
returns the result sorted by the 2. Primary key column does not accept any null values, where as a unique key
column that is passed column accept one null value. 
 
What is deferred name resolution in
+22   Recommend this on Google
SQL Server?

38 comments:

Anonymous June 18, 2011 at 4:38 PM


I have always thought that only Delete can be rolled back.
Reply

Replies

Anonymous December 15, 2013 at 1:30 AM


ya that is correct only delete can be rollback....but
truncate is faster than delete :) so u were right

Anonymous December 28, 2014 at 7:12 PM


Truncate can be rolled back until it is committed.

Reply

Anonymous June 26, 2011 at 11:28 PM


what is the importance of index in a table?
Reply

Replies

Anonymous April 13, 2012 at 11:32 PM


Use for shorting data.

srikanth kalyan January 10, 2013 at 8:47 PM


Fast Access the data

Reply

Anonymous August 8, 2011 at 2:13 AM


Hi Venkat,
Since Truncate is not Logged, How is it possible to roll it back?
Reply
http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions.html 3/9
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions

Reply

Replies

Anonymous January 6, 2013 at 10:31 PM


DELETE and TRUNCATE both can be rolled back when
surrounded by TRANSACTION if the current session is
not closed. If TRUNCATE is written in Query Editor
surrounded by TRANSACTION and if session is closed,
it can not be rolled back but DELETE can be rolled
back.

Anonymous February 24, 2014 at 10:30 AM


In either command if a transaction is commited can it
be rolled back?

Anju Renjith March 7, 2014 at 3:02 AM


If the transaction is committed, it can not be rolled
back!

Anonymous August 19, 2014 at 2:41 AM


TRUNCATE command is used to delete complete data
from an table.

Reply

Anonymous August 31, 2011 at 10:18 AM


truncate cant be roll back........
Reply

Amit September 1, 2011 at 8:14 AM


Most of the web sites say Truncate cannot be rolled back. That
is not true. I have tested this on SQL Server 2008. Truncate can
be rolled back. If you want try truncate yourself follow these
steps.

Step 1: Truncate the table as part of the transaction, but do


not commit.
Begin Tran
Truncate Table tblProduct

Step 2: Now issue a select statement. You will see no rows in


the table.
Select * from tblProduct

Step 3: Now issue a rollback statement, to rollback the


truncate operation.
Rollback

http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions.html 4/9
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions

Step 4: Now issue a select statement. You will see all the rows
in the table. This proves that Truncate can be rolled back.
Select * from tblProduct
Reply

Replies

Anonymous November 21, 2012 at 6:24 PM


Yes, you are right. Thanks for your step by step
information.

mukesh patil June 7, 2016 at 12:32 AM


Nice explanation amit

Reply

Current September 8, 2011 at 6:30 AM


Truncate can be rolled as Amit demonstrated but you can't
create a trigger on it.
Reply

Anonymous September 29, 2011 at 4:05 AM


this is kishor,
i think a cluster index get created by default when we create
primary key..and a non‐cluster index get created when we
create unique key
Reply

Anonymous November 7, 2011 at 10:01 AM


Even Truncate can be roll back provided if you start the
statment with BEGIN TRAN...
Reply

Anonymous November 21, 2011 at 12:45 AM


I think truncate in not rollback due to there is no log file
created for this ...vijay raj
Reply

gurprem singh January 4, 2012 at 3:16 PM


what is the importance of index in a table?
Re: Index are only way to make fast retrieve of data.As like in
book if we know index Number we can find page easy.Same way
if our table contain millions of records it makes easy and fast
search.There are two types of indexes cluster and non cluster.
Reply
http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions.html 5/9
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions

Reply

Atul Verma February 25, 2012 at 9:00 PM


Excellent article..Good for beginners..!!!
Reply

Anonymous June 13, 2012 at 3:52 PM


Hi, the distinction between drop, delete and truncate is nice
and explains the concepts very well. Great going...
Reply

Anonymous July 26, 2013 at 12:00 PM


what is clustered and non‐clustered index?
Reply

Replies

vikas sharma December 19, 2015 at 4:03 AM


Clustered
Clustered indexes sort and store the data rows in the
table or view based on their key values. These are
the columns included in the index definition. There
can be only one clustered index per table, because
the data rows themselves can be sorted in only one
order.
The only time the data rows in a table are stored in
sorted order is when the table contains a clustered
index. When a table has a clustered index, the table is
called a clustered table. If a table has no clustered
index, its data rows are stored in an unordered
structure called a heap.
Nonclustered
Nonclustered indexes have a structure separate from
the data rows. A nonclustered index contains the
nonclustered index key values and each key value
entry has a pointer to the data row that contains the
key value.
The pointer from an index row in a nonclustered index
to a data row is called a row locator. The structure of
the row locator depends on whether the data pages
are stored in a heap or a clustered table. For a heap,
a row locator is a pointer to the row. For a clustered
table, the row locator is the clustered index key.
You can add nonkey columns to the leaf level of the
nonclustered index to by‐pass existing index key
limits, 900 bytes and 16 key columns, and execute
fully covered, indexed, queries. For more
information, see Create Indexes with Included
Columns.

Reply

http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions.html 6/9
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions

dbsreddy September 17, 2013 at 1:55 PM


What does SET NOCOUNT ON do?
Reply

Replies

sailaja December 14, 2015 at 7:34 PM


Set nocount on off the message how many rows
affected and it is useful in procedures because it
reduces network traffic.

mukesh patil June 7, 2016 at 12:32 AM


yes you are right sailaja

Reply

Ed Tamakloe June 21, 2014 at 5:31 PM


Very, very nice videos on SQL, great job. my question is can I
pass the 70‐461 exam by watching these videos? in otherwise,
those the videos follow the exam objective. your response to
this question will be greatly appreciated.
once again, thanks for all the great videos.
Reply

Anonymous October 1, 2014 at 3:36 AM


Hi ALL
When a TRUNCATE Table statement is executed the data in the
table gets deleted(also memory is deallocated).It implies that
the Truncate statement affects the data.Then why is it
categorized under DDL statements.

So,Why is a TRUNCATE DDL and not DML?

Thanks in advance.
Reply

Replies

Anonymous November 13, 2015 at 4:58 AM


I dont know whether u r still looking for the ans or
not.. but may be usefull for me if i am wrong...
Asper my knowledge tough truncate affects data
indirectly .. the operation is not done at data level
rather its done at table level...
So, Truncate is categorized under ddl...
Correct me if i am wrong..

http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions.html 7/9
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions

Manoj Sharma December 24, 2015 at 1:39 AM


This is Manoj Sharma
truncate command is categorized under ddl because it
affect definition of table , i mean when you truncate a
table it perform two task deleting rows and reseeding
the seeds of identity column thats why it comes under
ddl.

Reply

rakesh sharma September 23, 2015 at 9:47 PM


What is use of primary key and unique key
Reply

Replies

Anonymous November 18, 2015 at 12:50 AM


Primary key doesn't allow null values, whereas unique
key allows.

Vicky July 31, 2016 at 11:25 PM


by default Primary key is a clustered index, where as
unique is a non clustered index

Reply

Unknown December 8, 2015 at 8:42 AM


Hi Everybody,
Can v get all Sql Clauses in a Single Query?
Reply

unknown January 17, 2016 at 8:45 AM


Hi venkat,

There is no rollback option in sql server so how we can rollback


the changes?
Reply

Vicky July 31, 2016 at 11:16 PM


what is #table and ##table.
Reply

Anonymous August 28, 2016 at 11:37 PM

http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions.html 8/9
12/24/2016 SQL Server Interview Questions: Basic SQL Server Interview Questions

#table is a local temp table which is used for that particular


window and gets deleted when connection is closed and ##table
is global temp table which is used by all the windows and
servers but this is also get deleted when the connection of the
server get closed and both does not occupy any memory
Reply

Enter your comment...

Comment as:  Select profile...

Publish
  Preview

If you are aware of any other sql server questions asked in an


interview, please post them below. If you find anything missing or
wrong, please feel free to correct by submitting the form below.

Newer Post Home

Subscribe to: Post Comments (Atom)

 
Disclaimer ­ Terms of use ­ Contact Us

http://venkatsqlinterview.blogspot.in/2011/05/basic­sql­server­interview­questions.html 9/9

You might also like