I have a stored procedure which contains one "user defined table type" parameter in Microsoft SQL Server. I am passing "Data Table" as parameter value to the stored procedure in C#. I would like to know how to pass Json data from node js as "Data Table" to this stored procedure.
User-defined table type :
CREATE TYPE [dbo].[TpUserRights] AS TABLE
(
[ConfigId] [int] NULL,
[FormId] [int] NOT NULL
)
Stored procedure:
CREATE PROCEDURE [dbo].[SpMergeUserRights]
(@UserRights TpUserRights ReadOnly)
AS
BEGIN
MERGE ModuleUserConfig AS [Target]
USING @UserRights AS [Source] ON [Target].ConfigId = [Source].ConfigId
WHEN NOT MATCHE BY TARGET
THEN
INSERT (ModuleId, FormId, UserId, CreatedBy)
VALUES (@ModuleId, [Source].FormId, @UserId, @CreatedBy)
WHEN MATCHED
THEN
UPDATE
SET FormId = [Source].FormId,
UserId = @UserId,
ModifiedDate = GETDATE(),
ModifiedBy = @CreatedBy;
END