|SQL - Structured Query Language|
When alter view, SQL Server takes an exclusive schema lock on the particular view. When the lock is granted, and there are no active users of the view, SQL Server deletes all copies of the view from the procedure cache and recompiled when starts view execution.
ALTER VIEW permissions default to members of the db_owner and db_ddladmin fixed database roles, and to the view owner. The following query is used to alter view that helps to list out System Department Employee Detail by using SQL join concept.
-- Example 55 --
ALTER VIEW EmpDept
SELECT EMP.Emp_Code, EMP.Emp_Name, EMP.Dept_Code, DEPT.Dept_Name FROM EMP, DEPT
WHERE EMP.Dept_Code = DEPT.Dept_Code
AND DEPT.Dept_Name = 'System'
SELECT * FROM EmpDept
Query Output Screen
* * * * *