Get advice
Article

Dynamic SQL: What you need to know

· Adrian Sullivan

I use Dynamic SQL queries for everything.. yes even for buttering my bread and putting on my socks.

Yes, there are some security risks when using Dynamic SQL, but I know the risks and manage the implementation on code very carefully.

In most instances this relates to script I run to manage stuff or reports.

Where to begin:

  1. Erland Sommarskog, dude you have made my life so much easier with this post. I keep it open in my browser at all times. The depth of information with regards to Dynamic SQL is really something special. Thanks Erland http://www.sommarskog.se/dynamic_sql.html
  1. Pinal Dave, I cannot even begin to describe how much I have learned from Mr Pinal Dave on http://blog.sqlauthority.com. Thank you so much. http://blog.sqlauthority.com/tag/dynamic-sql/

There are a lot of things about Dynamic SQL that people do not know about when they start writing some fancy procedures and end up wrecking everything on the server.

Some of the considerations you need to think about as your coding skills improve in SQL and especially Dynamic SQL are:

  1. Set-Based Thinking
  2. Using table variables especially in DSQL
  3. Execution Plan Caching
  4. My posts that might be related
  5. Execution plan’s Plan A
  6. Indexes
  7. My posts that might be related.. but possibly not.. who knows these days a. Help! My server ate my SQL indexes
Not sure who you need?

Tell us what is going on. A senior DBA reads every message and points you at the right next step, even when that is not us. A free read-only check will tell you whether this one is sitting in your estate.

Get pointed in the right direction

← All posts