Based on a comment by Ehsan Sajjad, one way is to record a stored procedure that has a READONLY parameter that is a custom table type .
Suppose you want to insert paste contacts consisting of a first and last name, here is how you do it: 1) Create a table type:
CREATE TYPE [dbo].[MyTableType] AS TABLE( [FirstName] [varchar](50) NULL, [LastName] [varchar](50) NULL ) GO
2) Now create a saved process that uses the specified table type:
CREATE PROC [dbo].[YourProc] @Names AS MyTableType READONLY AS GO
3) On the .NET side, pass the parameter as System.Data.SqlDbType.Structured This usually involves creating a data table in memory, then adding rows to it, and then using this DataTable as an @Names parameter. NOTE. A DataTable is considered memory intensive - be careful and comment on your code to make sure that it does not cause a resource problem on your server.
ALTENATIVE SOLUTION Use the approach described here: fooobar.com/questions/7782 / ... The solution is designed for DELETE, but can be adapted to be inserted or updated.
source share