Kenneth Fisher shows how to include table-valued parameters in a dynamic SQL query:
Recently I did a presentation on dynamic SQL. In the presentation I pointed out the similarity of using sp_executesql to creating a stored procedure to do the same task. After the session I was asked: If that’s the case, can I pass a TVP (table valued parameter) into sp_executesql?
Awesome question! Let’s give it a shot.
Read on to see how to do this.