Reputation: 1205
the statement is,
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
the error is,
Msg 120, Level 15, State 1, Procedure CDG_LoadData, Line 1641 The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns.
the insert and select contains same number of columns.
Upvotes: 1
Views: 76
Reputation: 93694
You need to remove parenthesis from CURRENT_USER
. Current_User
is not a inbuilt function. It
Returns the name of the 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
Upvotes: 3