-4
insert into Employee_Document 
values(FristName, LastName, BeginWeek, EndWeek, 
       Hrs_Mon, hrs_tues, Hrs_Wed, Hrs_Thu, Hrs_Fri, Total_Hours,
       TaskDesc_Mon, TaskDesc_Tues, TaskDesc_Wed, TaskDesc_Thu, TaskDesc_Fri, '')

select 
   FristName, LastName, BeginWeek, EndWeek, 
   TotalHours where TimeSheetDate='31-12-2012' AS Hrs_Mon,'08:00:00',
   TotalHours where TimeSheetDate='02-01-2013' AS Hrs_Wed,
   TotalHours where TimeSheetDate='03-01-2013' AS Hrs_Thu,
   TotalHours where TimeSheetDate='04-01-2013' AS Hrs_Fri,
   TaskDescription where TimeSheetDate='31-12-2012' AS TaskDesc_Mon,
   TaskDescription where TimeSheetDate='02-01-2013' AS TaskDesc_Wed,
   TaskDescription where TimeSheetDate='03-01-2013' AS TaskDesc_Thu,
   TaskDescription where TimeSheetDate='04-01-2013' AS TaskDesc_Fri,'' 
from 
   vw_TSDailyTotalHoursTaskDesc)

由于我是 SQL Server 的新手,因此此语句是否有任何错误。

提前致谢。

4

2 回答 2

0

(哈哈)

好的,首先需要删除关键字 VALUES,基本的插入语法是:

INSERT [INTO] tablename (column list...) VALUES (literals...)

或者

INSERT [INTO] tablename (column list) SELECT...

由于上面是后者,只需完全删除 VALUES 即可。

接下来,根本就没有这样的名为''的列,不能(如果真的不正常的话,极限可能是['']),把它整理出来。

最后,我猜你想用这个做什么

TotalHours where TimeSheetDate='31-12-2012' AS Hrs_Mon,'08:00:00',

可能是这样的

CASE WHEN TimeSheetDate='31-12-2012' THEN TotalHours ELSE '08:00:00' END AS Hrs_Mon,

或者其他的东西??

于 2013-01-30T15:31:29.107 回答
-2

据我所知,唯一不正确的是在第一行你有不需要的单词值。

于 2013-01-30T13:21:11.920 回答