SQL Server Graph Edge Insert

199 views Asked by At

In my model, I have two nodes ACCOUNT and WARNING. ACCOUNT can have zero to many WARNING.

the ACCOUNT node has multiple columns with the ACCOUNTNUMBER as the unique columnn.

the WARNING node has WARNINGCODE, WARNINGDESCRIPTION, and EXPIRATIONDATE. I also create an edge table HAS_A_WARNING, which besides the usual columns, I have ExpirtionDate.

I have a staging table that has the ACCOUNTNUMBER, WARNINGCODE, WARNINGCODEDESCRIPTION,EXPIRATIONDATE. when I run the following statement, I get an error:

Msg 116, Level 16, State 1, Line 17 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. Msg 213, Level 16, State 1, Line 2 Column name or number of supplied values does not match table definition.

INSERT INTO [dbo].[HAS_A_WARNING] 
values
(

 (SELECT
   ac.$node_id,
   w.$node_id,
   acw.ExpirationDate

 FROM dbo.Account ac
 join Stage.AccountWarning acw
 on acw.AccountNumber = ac.ACCOUNTNUMBER
 join dbo.Warning w
 on w.WarningCode = acw.WarinngCode)

)
0

There are 0 answers