From the course: Complete Guide to Advanced SQL Server
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
SCHEMABINDING a view - SQL Server Tutorial
From the course: Complete Guide to Advanced SQL Server
SCHEMABINDING a view
Views are defined with SELECT statements that reference database tables. This can cause issues if the structure of the underlying table changes after the view is created. For instance, if a table is dropped or a column is renamed. Database designers can prevent this disconnect from happening with an additional option called schema binding. I'm going to create a view that shows some information from the Sales.CustomerTransactions table. We're going to call this view Sales.OutstandingBalance. I'm using a WHERE clause here to only return transactions that have a balance due. This occurs when the customer hasn't fully yet paid their bill. Then we can test out the view by selecting everything from the Sales.OutstandingBalance view. So I'm going to run Line 6 through 22. So this is our starting point. We have 84 rows returned for all of the transactions with a balance due. Now, let's suppose that a structural change is made to the database. I'm going to scroll down on my script here and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.