插入查询中缺少什么?

时间:2016-07-24 22:04:58

标签: sql sql-server

SET IDENTITY_INSERT Dim_Date ON

INSERT INTO Dim_Date ([Date_Key], [Date], [Full_Date], [Day_Of_Month], [Day_Name], [Day_Of_Week], [Day_Of_Week_In_Month], 
            [Day_Of_Week_In_Year], [Day_Of_Quarter], [Day_Of_Year], [Week_Of_Month], [Week_Of_Quarter], [Week_Of_Year], 
            [Month], [Month_Name], [Month_Of_Quarter], [Quarter], [Quarter_Name], [Year], [Year_Name], [Month_Year], 
            [MM_YYYY], [First_Day_Of_Month], [Last_Day_Of_Month], [First_Day_Of_Quarter], [Last_Day_Of_Quarter], 
            [First_Day_Of_Year], [Last_Day_Of_Year], [Is_Holiday], [Is_Weekday], [Holiday]) 

SET IDENTITY_INSERT Dim_Date OFF

DECLARE @StartDate DATETIME = '01/01/2010' -- Starting value of date range
DECLARE @EndDate DATETIME = '08/12/2016' -- End Value of date range

错误消息说明

  

关键字“SET”附近的语法不正确

[假日]和SET之间缺少什么?

感谢。

1 个答案:

答案 0 :(得分:5)

您只有一半INSERT声明。为简洁起见,您有:

INSERT Into Dim_Date ([Date_Key], ..., [Holiday])

这意味着您忘记了要插入的值。更像是这样:

INSERT Into Dim_Date ([Date_Key], ..., [Holiday]) VALUES ('some value', ..., 'another value')

完成INSERT语句以包含您要插入的内容。否则,你期望插入什么?