添加批准日期列

时间:2013-12-27 08:07:01

标签: sql sql-server

我想从我尝试的批准表中添加批准日期,但它不起作用

ALTER procedure [dbo].[spdocuments]
as
    SELECT    dbo.DocumentInfo.DocID as DocumentID,
dbo.DocumentInfo.DocName as DocumentName, 
dbo.DocumentInfo.UploadedDate as UploadedDate , 

  dbo.DocumentInfo.Uploadfile as FileUploaded, 

    dbo.DocumentInfo.UploadedBy as  UploadedBy,
    dbo.Department.DepType as Department, 
 dbo.ApproveType.ApproveType as Status

FROM         dbo.DocumentInfo INNER JOIN
                      dbo.ApproveType ON dbo.DocumentInfo.ApproveID = dbo.ApproveType.ApproveID INNER JOIN
                      dbo.Department ON dbo.DocumentInfo.DepID = dbo.Department.DepID 
                      left join dbo.Approval on dbo.DocumentInfo.ApproveID= dbo.Approval.ApproveID 
                      AND dbo.DocumentInfo.DocID= dbo.Approval.DocID

而在批准表和此批准的数据中存在

SeqNO   DocID   ApproveID  AppoveBy DesigID          ApproveDate
258 30  1       sundus  1         2013-12-25 18:34:47.347
259 30  1       kaneez  2        2013-12-25 18:34:47.347
260 31  1        wajihazeb  3      2013-12-26 12:17:37.150

它像我这样返回

DocumentID  DocumentName    UploadedDate    FileUploaded    UploadedBy  Department  Status
30  computer science report 2013-12-25 18:31:26.420 dotnetcodes.docx    noreen  Computer Science    Pending
31  manual hr   2013-12-26 12:16:54.830 The Business Memo.doc   kulsoom Human Resource  Approve
31  manual hr   2013-12-26 12:16:54.830 The Business Memo.doc   kulsoom Human Resource  Approve
31  manual hr   2013-12-26 12:16:54.830 The Business Memo.doc   kulsoom Human Resource  Approve

1 个答案:

答案 0 :(得分:0)

最后一行是罪魁祸首

dbo.Approval on dbo.Approval.ApproveID = dbo.Approval.ApproveDate

永远不会给出任何结果