Executing a Dynamically Created Script with Returning a Parameter SP_EXECUTESQL - MSSQL
Example of returning a parameter when executing a dynamically created query. May be useful in cases where you need to return parameters for further processing in a script, for example, a procedure. We will use this for <b>sp_executesql</b>.