From the course: SQL Server 2014 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Understanding advanced options of views

Understanding advanced options of views - SQL Server Tutorial

From the course: SQL Server 2014 Essential Training

Start my 1-month free trial

Understanding advanced options of views

- In the previous example we created a view called CustomerNameWithAccountNumber. If we right click on that and go to Design we can see that it utilizes the Customer table and the Person table. Particularly it uses the FirstName and LastName fields of the Person table. If someone were to go behind this and modify the Person table, for example, if the removed the FirstName field or even just changed the name of that field we would have a problem, it would break our view. SQL Server has a mechanism to try to prevent this and I'll demonstrate that to you now. We'll need to close out of this interface, right click on the name of the view, go to the option called Script View as and we will want to ALTER it. So I'd like to Script View as, Alter To, New Query window and if necessary you'll need to connect to your particular SQL instance. So this interface allows me to modify the view. I could change the SQL statement here if I wanted to but that's not what I came to do. Instead I want to add…

Contents