Please refer the below code.
1) How can I insert tias.InventoryID
in to @TempIDList
. I am getting a syntax error saying tias
is undefined.
2) I can avoid the issue in (1) by selecting it using the SELECT
statement in the below code. But it opens another issue saying Column Count Mismatch
.
How can I do both the tasks at the same time.
Task 1 : Inserting in to [Product].[ProductSupplier]
table.
Task 2 : Inserting Tast 1's output in to @TempIDList
INSERT INTO
[Product].[ProductSupplier](ProductID,SupplierID)
OUTPUT INSERTED.ID,tias.InventoryID INTO @TempIDList(ProductID,InventoryID)
SELECT
tias.ProductID
,tias.FromID
FROM
[Product].[ProductSupplier] ps
INNER JOIN @TempInventoryStock tias ON tias.SupplierID = ps.ID
WHERE
tias.SupplierID <> tias.FromID;