• Let's not forget that this is also about the ability to read dynamic SQL. And it doesn't matter if you like or dislike dynamic SQL at some point you are going to have to be able to read it.

    Here is a simple example of generating a series of commands to print out the name of a database.

    declare @sql nvarchar(max)

    SET @sql = N'SELECT ''PRINT ''''''+name+''''''''' +

    N' FROM sys.databases'

    EXEC sp_executesql @sql

    Take a minute and count up the number of 's. Or better yet try to write it yourself. And remember that this is a SIMPLE example.

    Kenneth FisherI was once offered a wizards hat but it got in the way of my dunce cap.--------------------------------------------------------------------------------For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/[/url]Link to my Blog Post --> www.SQLStudies.com[/url]