ENCRYPTION

The ENCRYPTION attribute causes the view definition to be stored as encrypted text. Without encryption, the definition would be viewable via SSMS or by using the sys.syscomments or sys.sql_modules catalog views. This feature is also available for stored procedures and other database code that you may want to protect. One issue to consider when you create a view using the ENCRYPTION option is that this option prevents the view from being published as part of SQL Server replication.

The following example shows the creation of one of the prior views with the ENCRYPTION attribute:

IF  EXISTS (SELECT * FROM sys.views WHEREobject_id= OBJECT_ID(N'[Sales].[vw_OrderSummary]'))DROP VIEW [Sales].[vw_OrderSummary] ...

Get Microsoft SQL Server 2014 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.