RiddleMeThis
MIS
Could someone please explain to me the difference in how a stored proc runs compared to just raw sql outside of a stored proc?
I created a query which creates 2 temp tables and loads them with data, then creates a 3rd temp table, inserts some rows with titles in the first column, and populates the 2nd and 3rd columns with counts and sums from the first 2 temp tables.
This query takes 1 second to run, but when put into a SProc with the date being passed as a parameter it takes 1 minute and 16 seconds.
Obviously this is a significant difference, especially given both methods use the EXACT same code.
Any ideas?
I created a query which creates 2 temp tables and loads them with data, then creates a 3rd temp table, inserts some rows with titles in the first column, and populates the 2nd and 3rd columns with counts and sums from the first 2 temp tables.
This query takes 1 second to run, but when put into a SProc with the date being passed as a parameter it takes 1 minute and 16 seconds.
Obviously this is a significant difference, especially given both methods use the EXACT same code.
Any ideas?