声明是,
INSERT INTO int_in_sales_cosmic_hdr
([sales_id],
[description],
[create_date],
[update_date],
[user_id],
[start_date],
[period_week],
[action],
[is_forecast])
SELECT DISTINCT Cast(Datepart(year, [create_date])AS NVARCHAR(10))
+ Cast(Datepart(week, [create_date])AS NVARCHAR(10)),
[description],
[create_date],
Getdate(),
CURRENT_USER(),
[start_date],
[period_week],
[action],
[is_forecast]
FROM #temp_sales
错误是,
Msg 120,Level 15,State 1,Procedure CDG_LoadData,Line 1641 The INSERT语句的选择列表包含的项目少于 插入列表。 SELECT值的数量必须与数量匹配 INSERT列。
insert和select包含相同数量的列。
答案 0 :(得分:3)
您需要从CURRENT_USER
中删除括号。 Current_User
不是内置函数。它
返回当前用户的名称
INSERT INTO int_in_sales_cosmic_hdr
([sales_id],
[description],
[create_date],
[update_date],
[user_id],
[start_date],
[period_week],
[action],
[is_forecast])
SELECT DISTINCT Cast(Datepart(year, [create_date])AS NVARCHAR(10))
+ Cast(Datepart(week, [create_date])AS NVARCHAR(10)),
[description],
[create_date],
Getdate(),
CURRENT_USER,
[start_date],
[period_week],
[action],
[is_forecast]
FROM #temp_sales