2017-10-18 17 views
0

複数の結合テーブルの値を持つテーブルに挿入しようとしています。計算された列を挿入する方法

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. 

私は "計算列" を挿入する方法がわからないです:私はエラーを取得する

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) 

は、ここに私のコードです。私はテーブルを変更すべきだと言った投稿を言う。しかし、私は...ここ

がリンクである...これらの値を挿入したい How do you add a computed column to a Table?

+3

全体計算された列のポイントは、 'insert'の値を設定しないことです。 –

答えて

関連する問題