Send a Table-Valued Parameter to a MS SQL Stored Procedure in Mule 4

Introduction

Most of us have called a stored procedure in Mule to pass data to or receive data from database tables. However, one interesting variation of sending data via table-valued parameter (TVP) is not so commonly used. This article will show you how to send data in a TVP format to an MS SQL table via a stored procedure in Mule 4.

Before we proceed with the actual Mule development, let's first understand what a table-valued parameter is. As the name suggests, it is a parameter where data is sent in the form of a table, comprised of columns and rows. Within the database, table-valued parameters are declared by using user-defined table types. The main purpose of a TVP is to pass multiple values for a record, e.g. Multiple contact number values for a user record merged in the record itself. The benefit is that it associates the values, maintains the sequence, and reduces code complexity in the stored procedure.