SQL Server 2008 R2 allows encryption of functions and stored procedures. Adding the WITH ENCRYPTION option when creating a function or stored procedure will encrypt it, preventing viewing of the source code or generation of a script. Examples show encrypting a function that calculates the sum of two numbers and a stored procedure that calculates a sum and outputs the result. Both encrypted objects cannot be modified or have their scripts viewed afterwards.