You are on page 1of 4

12/24/2016 SQL Server Interview Questions: SQL Server Interview Questions on Views ­ Part 1

2   More    Next Blog» Create Blog   Sign In

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

If you like this website, please share


this site using g+1 button SQL Server Interview Questions on Views ­
+2   Recommend this on Google Part 1
{
Take: [“the”],
Android:
“course”
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.

 
What is a View in SQL Server?
You can think of a view either as a compiled sql query or a virtual table. As a
view represents a virtual table, it does not physically store any data. When you
query a view, you actually retrieve the data from the underlying base tables.

What are the advantages of using views?
Or 
When do you usually use views?
1. Views can be used to implement row level and column level security.

Example 1: Consider the tblEmployee table below. I don't want some of the
users to have access to the salary column, but they should still be able to
access ID, NAME and DEPT columns. If I grant access to the table, the users
will be able to see all the columns. So, to achieve this, I can create a view as
shown in Listing 1 below. Now, grant access to the view and not the table. So
SAP BI Training in Bangalore using views we can provide column level security.
Best SAP BI Training institute in Bangalore,
Marathahalli. Real time project based training
tblEmployee
provided by working software professionals
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/sql­server­interview­questions­on­views.html 1/4
12/24/2016 SQL Server Interview Questions: SQL Server Interview Questions on Views ­ Part 1

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

What is the difference between


Having and Where clause Listing 1 
Create View      vWEmployee 
What is the difference between a As 
Temporary Table and a Table Variable Select               ID, Name, Dept 
From                 tblEmployee
What is the use of COALESCE in SQL
Server Example 2: Let us say, we have a few users who should be able to access only
IT employee details and not any other dept. To do this, I can create a view as
SQL Server Interview Questions on shown in Listing 2 below. Now, grant access only to the view and not the table.
triggers So using views we can provide row level security as well. 
 
Difference between User Defined Listing 2 
Function and Stored Procedure Create View     vWITEmployees 
As 
SQL Server Interview Questions on Select              ID, Name, Dept 
Views ‐ Part 1 From                tblEmployee 
Where              Dept = 'IT'
SQL Server Interview Questions on
Views ‐ Part 2 2. Simplify the database schema to the users. You can create a view based on
multiple tables which join columns from all these multiple tables so that they look
Basic SQL Server Interview Questions like a single table.
on Joins
3. Views can be used to present aggregated and summarized data.
Explain Inner Join with an example
Example 1: Consider the tblEmployee table above. I want to aggregate the data
Explain Left Outer Join with an as shown in the image below. To do this I can create a view as shown in Listing
example 3. Now, you can simply issue a select query against the view rather than writing
a complex query every time you want to retrieve the aggregated data.
Explain Right Outer Join with an
example

Explain Full Outer Join with an


example

Explain Self Join with an example


Listing 3 
What is the difference between Index Select        Dept, Count(*) As Total  
Scan and Index Seek From          tblEmployee 
Group By   Dept 
Write a SQL Query to delete from a  
table that is involved in a SQL join If you can think of any other advantages of using views please post them
as comments, so they will be useful to other users like you.  
What are the advantages of using
stored procedures +2   Recommend this on Google

What are the different ways to


replace NULL values in SQL Server
http://venkatsqlinterview.blogspot.in/2011/05/sql­server­interview­questions­on­views.html 2/4
12/24/2016 SQL Server Interview Questions: SQL Server Interview Questions on Views ­ Part 1

4 comments:
SQL Server interview questions on
string manipulation functions
Anonymous February 12, 2012 at 4:30 AM
Write a Stored Procedure that takes
column name as a parameter and Some of other advantages of views...
returns the result sorted by the
column that is passed 1) Combines complex tables and can have required columns
from them.
What is deferred name resolution in 2) Index can be created on views (indexed Views) for faster
SQL Server? data retrieval.
3) View can be encrypted..make sure to store the source to
decrypt later.
4) Views can be granted to the user for access instead of
providing access of related tables used in it.
5) Parametrized views can be created using Inline UDF.
6) View can be materialized when indexed.

‐‐JP
Reply

Anonymous July 19, 2012 at 1:39 AM


Very nice.... :)
Reply

Bhagabat Dayal Dash January 7, 2016 at 7:14 PM


What is the different between the stored procedure and view
and use.
Reply

Anonymous January 23, 2016 at 9:17 AM


WITH SCHEMABINDING can be used in Views and T‐SQL
Functions, but not in Stored Procedures.

Objects that are schema bound can have their definition


changed, but objects that are referenced by schema bound
objects cannot have their definition changed.
Reply

http://venkatsqlinterview.blogspot.in/2011/05/sql­server­interview­questions­on­views.html 3/4
12/24/2016 SQL Server Interview Questions: SQL Server Interview Questions on Views ­ Part 1

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 Older Post

Subscribe to: Post Comments (Atom)

 
Disclaimer ­ Terms of use ­ Contact Us

http://venkatsqlinterview.blogspot.in/2011/05/sql­server­interview­questions­on­views.html 4/4

You might also like