From the course: Program Databases with Transact-SQL

Unlock the full course today

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

SchemaBind a view

SchemaBind a view - SQL Server Tutorial

From the course: Program Databases with Transact-SQL

Start my 1-month free trial

SchemaBind 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 the 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 six 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…

Contents