THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

Peter DeBetta's SQL Programming Blog

Peter DeBetta's blog about programming in SQL Server using technologies such as T-SQL, .NET, CLR, C#, VB, Visual Studio, and SQL Server Management Studio.

Crashing SQL Server via the CLR

This post is for developers and admins alike.

I have tried many ways to cause a crash in SQL Server 2005 by deploying assemblies with questionable code. To date, Safe and Eternal Access assemblies have not been able to cause any discernable grief, but Unsafe assemblies, on the other hand, have.

Now keep in mind that you need to be a sysadmin in SQL Server to even be able to add the Unsafe assembly, but once it's there, one line of code can bring your SQL Server to a screeching halt.

System.Environment.Exit

This will cause the SQL Server service to simply stop with no exceptions raised.

As for deploying Unsafe assemblies, I recommend avoiding it unless absolute necessary, since most everything that you will need to do can be done in a Safe assembly, with a rare need for even External Access.

Finally, as much as I think great things of the new CLR Integration in SQL Server 2005, my advice is always the same - "Use it with prudence."

Published Friday, June 30, 2006 10:28 AM by Peter W. DeBetta

Comments

No Comments
New Comments to this post are disabled

About Peter W. DeBetta

Peter DeBetta works as a Data and Cloud Solution Manager at DB Best, a Microsoft gold partner company. Peter has written courseware, articles, and books on topics such as development and SQL Server. Peter has spoken at conferences around the world, including TechEd, SQL PASS Community Summit, DevTeach, SQL Connections, DevWeek, and VSLive!

When Peter isn’t working, you can find him singing and playing guitar, taking pictures, working on DIY projects, woodworking, or simply enjoying life with his kids.
Privacy Statement