SHASHANGKA SHEKHAR'S BLOG

Hi, I am Shashangka Shekhar, Working with Microsoft Technologies. This is my personal blog where I share some of my experiences.

Views In SQL Server

Let’s create a SampleDB database fist with SQL Management Studio. Now we have to create a table in SampleDB.

Let’s Name the table as – Employee

Now insert data in new Employee table :

Now what is View?
Creates a virtual table whose contents (columns and rows) are defined by a query. Used to hide the complexity of the underlying database schema.

Syntax:

Let’s create a view based on our newly created table:

Let’s alter created view:

Let’s drop altered view:

When to use  View?

  1. To hide the complexity of the underlying database schema, or customize the data and schema for a set of users.
  2. To control access to rows and columns of data.
  3. To aggregate data for performance

Post a comment