Could you explain why dynamic SQL is recommended to be avoided? Is there a way that I can continue to use dynamic SQL and avoid its bad things?
http://www.sommarskog.se/dynamic_sql.html
If you do not understand all of this, go back and ask a question, but if there is no circulation, you should use dynamic SQl until you understand this article.
The main problem is SQL injection. People can enter data that can change the intent of your sql.
sp_executesql. http://msdn.microsoft.com/en-us/library/ms188001.aspx