I am working on an assignment where I have to create a database using SQL Server 2019. I am wondering how to create a function which uses the existing PK of one table and puts it into the FK of the linked table. I can't upload a picture of it. But here is a description of my two tables:
Table Item
:
Columns: itemID(PK), itemPackID(FK), description
......
Table ItemPack
:
Columns: ItemPackID(PK) ItemID(FK), quantity
...
In the Item
table, itemPackID
as a foreign key is holding NULL and I want to replace the NULL with the PK value of the ItemPack
table.