Why kaspencer, why -- so a user can cut and paste ... that is a heck of a way for a person to test their knowledge ...
Now if all you want is a method to inflate your ego ... then your suggestion would be appropriate ... but to test your knowledge inappropriate
Sudhir Chawal A darn good question
Exactly!. The whole point of the QoD is to test one's own knowledge, and the best way to do it is to try figuring the correct answer before pasting anything into the editor. Once the answer is submitted then it is OK to play with the sample statements and adjust them if necessary depending on one's settings. Today's question is a very good one indeed. It shows that sp_executesql is far more powerful than simple exec as it allows designing reusable dynamic SQL queries with multiple parameters in either direction (in or out) and possibly useful plan storage. It should always be used with caution as dynamic SQL can be subjected to injection attacks, but other than that the sp_executesql is a great feature.