I have a stored procedure that essentially takes data from a denormalized datawarehouse table and plugs certain data elements into a normalized table.
This requires running 84 INSERT statements for each denormalized record.
Rather than manually creating 84 insert statements in my sp, I'm running a loop to build the SQL string and then executing the SQL string using EXEC(@strSQL). Unfortunately this sp takes over 2 hours to run, although it is designed as an overnight process.
Question: Will I get better performance if I hardcode the INSERT statements rather than dynamically using the EXEC statement? If I used hardcoded SQL statements, I'm assuming the query plan is saved and optimized. Is the same true if I run a dynamic SQL statement using EXEC?
TIA for your input,
Rick
PS - I will test this theory eventually, I just don't want to start writing out 84 INSERT statements yet...especially if the performance benefit is going to be negligible.
This requires running 84 INSERT statements for each denormalized record.
Rather than manually creating 84 insert statements in my sp, I'm running a loop to build the SQL string and then executing the SQL string using EXEC(@strSQL). Unfortunately this sp takes over 2 hours to run, although it is designed as an overnight process.
Question: Will I get better performance if I hardcode the INSERT statements rather than dynamically using the EXEC statement? If I used hardcoded SQL statements, I'm assuming the query plan is saved and optimized. Is the same true if I run a dynamic SQL statement using EXEC?
TIA for your input,
Rick
PS - I will test this theory eventually, I just don't want to start writing out 84 INSERT statements yet...especially if the performance benefit is going to be negligible.