Remove the Dynamic code from my SQL sproc

  • I have a stored procedure that was created to run dynamically.  Other than me manually removing all the dynamic parts of the scripts, is there a script or a way to remove all the dynamic parts of it so I can step thru it and test parts of the script?

     

     

    • This topic was modified 1 year, 6 months ago by  GrassHopper.
    • This topic was modified 1 year, 6 months ago by  GrassHopper.
  • I cannot think of any way to facilitate picking apart a SP and running its dynamic parts separately without manually doing something. However, to cover some of the testing I would do to create Unit Tests for such a SP I would:

    First create a Unit Test that supplies the parameters that gives a specific result (perhaps more than one)

    Then I would out put the dynamic SP that gets created and check that it is being created as you expect it to be created.

    Then run this resulting dynamic SP to see if it is providing the results you expect it to provide and as important doing so in an efficient manner.

    Rinse and Repeat until you get a clean and efficient series of outputs

    Once you have this SP fully dissected and each set of results verified you can then outline the Unit Tests that you will need to run to make sure the SP is working as expected later on if any changes get made. This can be a golden time saver later on as change is inevitable but it is not always done right

     

  • You can print the SQL statement instead of executing it and then run it manually.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply