sql - Should I use sp_executesql or EXEC to run a stored procedure? -


I have a stored procedure that requires 2g SP calls multiple times. The only thing that changes is the parameters of the second SP:

  SELECT @ P1 = 5, @ P2 = 5 EXEC MyProc @ P1, @ P2 SELECT @ P1 = 0, @ P2 = 1 EXEC MyProc @ P1, @ P2  

Now if it was dynamic SQL I was running I know that sp_executesql would be better than EXEC, but in fact what I did in a sp Calling times, should I use sp_executesql or just as good as EXEC is shown above?

Thanks for any help.

Use EXEC like yours above EXEC archived protocol

sp_executesql is better than EXEC (@sqlstring) Usually where you have dynamic SQL, is not a stored proc because you are calling a stored procedure, Syntax is the best way for you


Comments