Hello, Guys In this tutorial we are going to learn what are Views in SQL Server. Views are a virtual table in SQL Server that does not contain its own data.

After Completing this tutorial you will be able to understand in SQL Server.

  • What are Views in SQL Server?
  • Why should we use View?
  • How to Create, Modify and Drop a View in SQL Server.

What are Views in SQL Server?

Views are database object that does not contain the data of itself It contains data from one or more tables. Views are a temporary object that is stored in the database. It is a virtual table that contains the select statements only. The purpose of using Views is to restrict the user from viewing certain columns from the tables. It provides the security mechanism because it hides the table name and certain fields from the user by providing the virtual table.

Why Should we use Views?

The purpose of using views in SQL Server is to provide security to the schema of the table in data because it encapsulates our table name and the fields that we don’t want to show to the user. The data inside the views are not stored permanently in the database. One more reason behind using a View in SQL Server is that if we have some complex type of join query from more than one table then instead of writing join query, again and again, we can create a View and use it anywhere.

The syntax of a View.

Where,

  • SchemaName specifies the name of Schema that owns the View.
  • ViewName specifies the name of View.
  • ENCRYPTION It will encrypt text of the ALTER VIEW statement in sys.syscomments.
  • SCHEMABINDING It ensures that the underlying table definitions can not be modified so as to affect the VIEW.
  • VIEW_METADATA It will ensure that SQL Server has metadata about the VIEW.
  • The Expression specifies the ColumnNames or Calculative values.
  • Tables species the name of Table in the database.
  • Where Condition This is Optional that specifies the condition on the basis of which we want to get records.

Example using View:

Let’s take a look at how to create a view in SQL Server. Before creating a view we need to create a table and insert few records in that table

Create a table called Employee:

Insert few records in Employee Table.

Create View.

Suppose I want to create a view to get records for those Employees who has salary less than 40000.

Run the Above Script.

Test the View.

To test the vwGetEmployee View run the following query.

The result will be:

Views

Alter a View.

You can alter a view using the Alter View Statement.

Syntax to Alter a View.

The example of Alter View:

Suppose I want don’t want to get EmployeeID from the View. Our view would like this.

Run the following query to test the result

You can see in the above snapshot there is no EmployeeID in the result set.

Views

How to Drop a View?

You can simply drop a View using the Drop Statement.

Syntax:

Where ViewName is the name of the View.

The example of Drop View:

Conclusion:

Hope you understand the concept of Views in SQL Server. I would appreciate your feedback, comments and suggestions.

View More:

Thank You.

 

31 Comments

  • Did you understand these truths on CBD OIL and Full Spectrum CBD Hemp Oil? Cannabinoids are isolated from hemp using supercritical CO2 extraction. Thanks to modern-day innovation, the resulting option is clean, complimentary of heavy metals and unnecessary waxes, naturally present in the plant, and the sucked liquid has a normal, oily consistency. CBD oil consists of cannabidiol as a base ingredient and may consist of only trace amounts of tetrahydroxycannabidiol (THC). Works as a memory enhancer, enhancing concentration and coordination of motions, removing swelling and frequent infections. It enhances the conduction of stimuli in the course of autoimmune diseases (multiple sclerosis, amyotrophic sclerosis). It is recommended by medical professionals and pharmacists as an antioxidant and compound that blocks the action of proinflammatory cytokines (proteins), e.g. in Crohn’s disease or ulcerative intestine. RSO oil has a low CBD content, while high THC. The synergistic (enhancing) action of CBD and THC relative to each other is utilized here. Both cannabinoids can do much more together than when used independently. Both marijuana oil type CBD and RSO likewise include other cannabinoids, such as cannabichromene (CBC) and cannabigerol (CBG). The trick is not, however, that CBD often has actually a composition expanded to include flavones, flavonoids, terpenes, terpenoids, amino acids and omega acids. The distinction is primarily due to motives guiding humankind to use one or the other item. CBD medical cannabis oil is a rather useful blend of cannabinoids, created to secure versus 21st century illness. It’s best to use all of these compounds together, as nature produced them and confined in marijuana inflorescences. It turns out that cannabidiol improves the impacts of cannabichromene (CBC) and cannabigerol (CBG), and flavones or flavonoids improve the absorption of these compounds. Omega-6 and omega-3 highly nourish the body and do not enable to change, which accelerate the aging process of the organism and enhance the advancement of cancer. Oil of marijuana in a type of hobby APR consists of percentages of CBD, balanced by the existence of THC. Makers concentrate on the synergistic impact of one compound relative to the other, while deserting the existence of CBC and CBG. Why such a decision? – Modern scientific research shows that CBD + THC deal with serious autoimmune diseases, while CBC or CBG show very little activity in the existence of both substances, just like flavones, flavonoids or terpenes, therefore their content in the service appears to be unneeded. In addition, the marijuana pressure from which THC and CBD are derived contain minimal amounts of other cannabinoids. RSO oil is totally unlawful in Poland, which is why it can not be gotten in any lawfully running store on the market. Obviously, there are a variety of amateur methods for acquiring it, however it’s great to know that compounds acquired synthetically in home labs are uncertain, untried, and the impact unknown. The solvent for the production of household RSO is normally fuel, alcohol and even kerosene, which instead of treating, poison. Alcohols and their like hinder cannabinoids, and so in truth, they don’t bring anything brand-new to the medical world. Marijuana oil has actually currently marked a new era in which man ceased to fear what is unknown, and started to rediscover what our forefathers had currently observed and utilize the significant capacity, initially glimpse, a little unusual relationships, associated generally with pathology. Medical marijuana, contrary to its name, does not indicate fermented female inflorescences and leaves consisting of psychedelic substances coiled in so-called “Joints”, however a beneficial oil without psychedelic THC. A standard person, after taking dosages of medical cannabis and attaining the suitable state of cannabinoids in the blood, can delight in increased resistance, reduced susceptibility to cancer, delayed aging and reduced threat of stroke or cardiac arrest. CBD oil contains cannabidiol as a base ingredient and may contain only trace quantities of tetrahydroxycannabidiol (THC). RSO oil has a low CBD material, while high THC. Both cannabis oil type CBD and RSO also contain other cannabinoids, such as cannabichromene (CBC) and cannabigerol (CBG). CBD medical marijuana oil is a rather useful blend of cannabinoids, developed to protect against 21st century illness. Oil of marijuana in a kind of hobby APR contains small quantities of CBD, balanced by the presence of THC.

  • I was recommended this web site by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my difficulty. You’re wonderful! Thanks!

  • Magnificent web site. Lots of useful info here. I am sending it to several friends ans also sharing in delicious. And of course, thanks for your effort!

  • Greetings! This is my first visit to your blog! We are a team of volunteers and starting a new project in a community in the same niche. Your blog provided us useful information to work on. You have done a extraordinary job!

  • Heya! I’m at work browsing your blog from my new iphone 4! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the superb work!

  • Wonderful post however I was wanting to know if you could write a litte more on this topic? I’d be very thankful if you could elaborate a little bit more. Thanks!

  • Currently, companies demand to see the specific work title you are hoping to apply for – and a general resume doesn’t have this. In addition, they immediately need to learn what positively makes you a better choice – and a general resume causes you to appear just like the tons of general resumes they have already received.

  • Hello my friend! I want to say that this post is amazing, nice written and include approximately all important infos. I’d like to see more posts like this.

  • Neat blog! Is your theme custom made or did you download it from somewhere? A theme like yours with a few simple tweeks would really make my blog jump out. Please let me know where you got your theme. Appreciate it|

  • Wow, awesome blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your website is magnificent, let alone the content!

  • Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an e-mail. I’ve got some creative ideas for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it expand over time.

  • Hello my friend! I want to say that this post is
    awesome, nice written and include almost all important infos.
    I’d like to look extra posts like this .

  • It is appropriate time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I wish to suggest you some interesting things or advice. Maybe you could write next articles referring to this article. I wish to read even more things about it!

  • I have been exploring for a little for any high-quality articles or blog posts on this kind of area . Exploring in Yahoo I at last stumbled upon this site. Reading this information So i’m happy to convey that I have a very good uncanny feeling I discovered just what I needed. I most certainly will make certain to do not forget this website and give it a glance on a constant basis.

  • Heya i’m for the primary time here. I came across this board and I to find It truly helpful & it helped me out a lot. I’m hoping to give one thing again and help others such as you aided me.

  • Remarkable issues here. I’m very glad to look your article.
    Thank you a lot and I am having a look ahead to contact you.
    Will you kindly drop me a mail?