使用 SQL 服务器在具有数据 table 参数的 table 中传递非数据 table 参数

Passing non-datatable parameter in the table with Datatable parameters using SQL Server

我在数据 table 中只有 2 columns/parameters,我试图通过存储过程将其插入 table。

但我还想添加另一个不在数据中的参数Table。

ALTER PROCEDURE [Job].[prc_A]
@JobId int = 0,
@StartDate datetime,
@EndDate datetime,
@JobPropertyValue as JobPropertyValuesType READONLY

这里是查询:

if(@JobId = 0)
    BEGIN
INSERT INTO TableA (StartDate, EndDate)
VALUES(@StartDate, @EndDate)
SELECT CAST(SCOPE_IDENTITY() as int)

---A New JobId gets created after first insert query. I want to add that JobId in Table B now with DataTable Parameters---
INSERT INTO TableB (JobId, JobPropertyType, JobValue)
    SELECT  __________________, JobPropertyType, JobPropertyTypeName  
    FROM @JobPropertyValue

(使用存储过程)

从 DataTable 插入不同 table 和其他两个参数中存在的 JobId 的正确方法是什么? (我不想对代码部分进行任何更改或直接在数据 Table 中添加 JobId(从 Table 获取它)) 我正在使用 Asp.Net Core in 发送请求。

假设 TABLEA 的 IDENTITY 列是 JobId,那么

if(@JobId = 0)
BEGIN
    INSERT INTO TableA (StartDate, EndDate)
    VALUES(@StartDate, @EndDate)
    set @jobid  = SCOPE_IDENTITY() 

    ---A New JobId gets created after first insert query. I want to add that JobId in Table B now with DataTable Parameters---
    INSERT INTO TableB (JobId, JobPropertyType, JobValue)
        SELECT  @jobid, JobPropertyType, JobPropertyTypeName  
        FROM @JobPropertyValue