sp_executesql
The sp_executesql command was introduced in SQL Server later than the EXEC command, mainly to provide better support for reusing execution plans. In this section, I’ll describe sp_executesql and its enhanced support in SQL Server 2005.
The sp_executesql Interface
The sp_executesql command is more flexible than EXEC(<string>) because it has an interface, which supports both input and output parameters. This capability allows you to create query strings with arguments that can reuse execution plans more efficiently than EXEC. The components of sp_executesql are very similar to those of a stored procedure, with the difference being that you construct the code dynamically. Those components include: a batch of code; parameter declaration ...
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.