17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

❑ Encrypt views when you don’t want others to be able to see your source code — either for commercial<br />

products or general security reasons, but also remember to keep a copy of your unencrypted<br />

code; it can’t be retrieved after you’ve encrypted it.<br />

❑ Using an ALTER VIEW completely replaces the existing view other than permissions. This<br />

means you must include the WITH ENCRYPTION and WITH CHECK OPTION clauses in the ALTER<br />

statement if you want encryption and restrictions to be in effect in the altered view.<br />

❑ Use sp_helptext to display the supporting code for a view — avoid using the system tables.<br />

❑ Minimize the user of views for production queries — they add additional overhead and hurt<br />

performance.<br />

Common uses for views include:<br />

❑ Filtering rows<br />

❑ Protecting sensitive data<br />

❑ Reducing database complexity<br />

❑ Abstracting multiple physical databases into one logical database<br />

Chapter 10: Views<br />

In our next chapter, we’ll take a look at batches and scripting. Batches and scripting will lead us right<br />

into stored procedures — the closest thing that <strong>SQL</strong> <strong>Server</strong> has to its own programs.<br />

Exercises<br />

1. Add a view called HumanResources.Managers in the AdventureWorks<strong>2008</strong> database that<br />

shows only employees that supervise other employees.<br />

2. Change the view you just created to be encrypted.<br />

3. Build an index against your new view based on the ManagerID and EmployeeID columns.<br />

323

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!