The solution to these problems is permission sets, which are named collections of access rights that can be assigned to an assembly. If an assembly tries to use a namespace or class not allowed by the permission set to which it belongs, an exception will be thrown and execution will stop. Through careful use of appropriate permission sets, a DBA can enforce access rights, even for non-trusted assemblies.
SQL Server includes three built-in permission sets: SAFE, EXTERNAL ACCESS, and UNSAFE. SAFE allows access to .NET's mathematical, string manipulation, and other standard libraries, as well as ADO.NET for data access. EXTERNAL ACCESS extends the rights allowed by the SAFE permission set, adding classes from namespaces such as System.IO for file system operations, and System.Net for network operations. The UNSAFE permission set is unrestricted—all namespaces and classes available within SQL Server can be accessed, and even unmanaged code is allowed. Be careful with the UNSAFE permission set!
Although the default permission sets are not editable, it is possible to create your own, as discussed in Niels Berglund's this blog post.
Do you have comments on this Ask the Expert Q&A? Let us know.
Dig Deeper on Microsoft SQL Server 2005
Related Q&A from Adam Machanic
SQL Server 2005 and T-SQL do have differences. The advantages and disadvantages would depend user environment as described by SQL Server 2005 expert... Continue Reading
SQL Server expert Adam Machanic highlights the differences to consider when weighing the move to SQL Server 2005 Enterprise and Standard Edtions. Continue Reading
Writing a generic audit trail trigger in SQL Server to keep track of inserts, deletes, and updates within a table is explained in this expert ... Continue Reading