使用 WITH ENCRYPTION WITH CHECK OPTION 选项并且包含函数列：

use pubs

if exists (select table_name from information_schema.views

where table_name = 'emprange')

drop view emprange

go

create view emprange (emp_id, fname, lname, pubid, job_id, rows)

with encryption

as

select emp_id, fname, lname, pub_id , job_id, @@rowcount

from employee

where job_id between 11 and 12

with check option

go

由于使用了WITH CHECKOPTION，所以当对视图进行修改时，将返回错误信息，比如执行以下语句：

update emprange

set job_id='5'

where emp_id='PCM98509F'

由于使用了WITH ENCRYPTION选项所以当执行以下语句时会看到很多乱码。

use pubs

go

select c.id, c.text

from syscomments c, sysobjects o

where c.id = o.id and o.name = 'emprange'

go

若表被垂直分割成多个子表使用视图重新装载表的数据：

create view comptable

as

select * from table1 union

select * from table2 union

select * from table 3

计算 northwind 数据库中，1997年的产品销售总量，通过视图实现。

create view "Product Sales for 1997" AS

SELECT Categories.CategoryName, Products.ProductName,

Sum(CONVERT(money,("Order Details".UnitPrice*Quantity*(1-Discount)/100))*100) AS ProductSales

FROM (Categories INNER JOIN Products ON Categories.CategoryID = Products.CategoryID)

INNER JOIN (Orders

INNER JOIN "Order Details" ON Orders.OrderID = "Order Details".OrderID)

ON Products.ProductID = "Order Details".ProductID

WHERE (((Orders.ShippedDate) Between '19970101' And '19971231'))

GROUP BY Categories.CategoryName, Products.ProductName