Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm an experienced programmer but I'm new to SQL/databases so please bare with me :).

One of my current tasks involve editing (and refactoring, if needed) a dynamic generated SQL statement in a stored procedure. Are there any "best practices" or "design patterns" that I can follow for writing stored procedures in general or better yet, stored procedures that generate long (300 lines) dynamic sql statements?

share|improve this question
add comment

closed as not a real question by Mark Storey-Smith, Max Vernon, dezso, RolandoMySQLDBA, Mat Jun 1 '13 at 9:08

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

up vote 5 down vote accepted

How about starting with this article, 'The Curse and Blessings of Dynamic SQL' by Erland Sommarskog?

share|improve this answer
    
Just in time .. same answers –  Kin May 31 '13 at 19:18
add comment

Best is to read The Curse and Blessings of Dynamic SQL by Erland Sommarskog.

Also read Using Dynamic SQL in Stored Procedures and Stored Procedures - Executing & Dynamic SQL

share|improve this answer
    
Travis beat you to answering the question. Thanks again for the answer. :) –  burnt1ce May 31 '13 at 19:43
1  
@burnt1ce as long as we all help the community .. its fine for me. At the end we are all here to help each other and learn. –  Kin May 31 '13 at 19:49
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.