我正在尝试使用来自多个连接表的值插入到表中。
这是我的代码:
INSERT INTO [dbo].[ORD_PURCHASING_GROUP_DTL]
([ORG_ID]
,[ORG_UNIT_ID]
,[PURCHASING_GROUP]
,[MASTER_CUSTOMER_ID]
,[SUB_CUSTOMER_ID]
,[ADDOPER]
,[ADDDATE]
,[MODOPER]
,[MODDATE]
,[CONCURRENCY_ID]
,[EFFECTIVE_BEGIN_DATE]
,[EFFECTIVE_END_DATE]
,[LAST_FIRST_NAME]
,[ACTIVE_FLAG]
)
(select 'SIAM', 'SIAM', CONCAT(@conf_name, '-', demo.DEMOGRAPHIC_CODE)
as PURCHASING_GROUP, demo.master_customer_id, 0, 'SIAM_MTG_PG_SQL' as
ADDOPER, GETDATE() as ADDDATE, NULL as MODOPER, NULL as MODDATE, 0,
demo.USER_D1 as EFFECTIVE_BEGIN_DATE, NULL as EFFECT_END_DATE,
cus_addr.Last_First_Name as LAST_FIRST_NAME , cus_status.ACTIVE_FLAG as
ACTIVE_FLAG
from cus_demographic as demo
join CUS_PRIMARY_EMPL_ADDR_MBR_VW cus_addr on
demo.MASTER_CUSTOMER_ID = cus_addr.MASTER_CUSTOMER_ID
join CUS_STATUS_VW cus_status on demo.MASTER_CUSTOMER_ID =
cus_status.MASTER_CUSTOMER_ID
where
1 = 1
and demographic_code in (
select RIGHT(pg.PURCHASING_GROUP, LEN(pg.PURCHASING_GROUP)-
CHARINDEX('-', pg.PURCHASING_GROUP))
FROM [ORD_PURCHASING_GROUP] as pg
where pg.PURCHASING_GROUP like concat(@conf_name, '%')
)
and demographic_subcode = @conf_name)
我收到错误:
Msg 271, Level 16, State 1, Line 82
The column "LAST_FIRST_NAME" cannot be modified because it is either a
computed column or is the result of a UNION operator.
Msg 271, Level 16, State 1, Line 82
The column "ACTIVE_FLAG" cannot be modified because it is either a computed
column or is the result of a UNION operator.
我不确定如何插入“计算列”。我说一个帖子,它说我应该改变桌子。但我想插入这些值......
这是链接...... How do you add a computed column to a Table?