जगदीश खोलिया: Schemabinding View

Monday, June 4, 2012

Schemabinding View

Schemabinding View Restirct you to made any change in tables you used in your View.
Example:

Suppose I have an table Employee(EmpID,EmpName, DOJ,Managerid,DepartID)

Now am Creating a view

Create View EmployeeDetails
with Schemabinding
as
Select EmPid, EmpName,DOj,ManagerId,DepartID from Employee

after it just try to execute delete table and alter table and delete column of employee table.

Sql server will not allow to change table schema. Because you are having Schema dependency.First you need to delete View then only database will allow to modify table.

If you are using Normal View. Sytem will Allow you to delete or modify table but when you run your View next time it will display error.

No comments: