Conclusion

By now, you probably have realized that dynamic SQL holds within it great power and, at the same time, great risk. By using dynamic SQL wisely, you can get great performance benefits and flexible solutions. Using it unwisely often leads to lengthy, inefficient code that is open to attacks that can cause havoc in your system.

Get Inside Microsoft® SQL Server™ 2005 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.