我試過這個存儲過程來顯示文件:只批准文件應顯示
ALTER procedure [dbo].[financespmanager]
@DepID int
as
SELECT
dbo.DocumentInfo.DocID as DocumentID,
dbo.DocumentInfo.DocName as DocumentName,
dbo.DocumentInfo.Uploadfile as FileUploaded,
dbo.Department.DepType as Department,
dbo.DocType.DocType as Document,
dbo.DocumentInfo.UploadedBy as UploadedBy,
dbo.Approval.AppoveBy,
dbo.ApproveType.ApproveType as Status
FROM
dbo.DocumentInfo
INNER JOIN
dbo.Approval ON dbo.DocumentInfo.DocID = dbo.Approval.DocID
INNER JOIN
dbo.ApproveType ON dbo.Approval.ApproveID = dbo.ApproveType.ApproveID
INNER JOIN
dbo.Department ON dbo.DocumentInfo.DepID = dbo.Department.DepID
INNER JOIN
dbo.DocType ON dbo.DocumentInfo.DocTypeID = dbo.DocType.DocTypeID
WHERE
DocumentInfo.DepID = @DepID
現在,當我測試查詢拿給我這個樣子
DocumentID DocumentName FileUploaded Departmen UploadedBy AppoveBy Status
25 css dsfsdf.docx Computer edward halten Rejected
18 hr HR.docx Computer john halten Approved
19 eco eco 2.docx Computer kety halten Rejected
24 plan December8.pdf Computer edward halten Approved
現在,這裏我想說明只批准文件沒有拒絕和正在申請的文件
我該怎麼做?
當我嘗試你的查詢時,它顯示我errro」轉換失敗時轉換varchar值'批准'爲數據類型int「 – user2931015
@ user2931015:看到我的更新 - 你可能有一個名爲'狀態' ' - 而且你還在'dbo.ApproveType.ApproveType'列中使用'Status'作爲列別名 - 這相當令人困惑,我會說... –
當我像這樣使用AND AND Status ='Approve'then它顯示我錯誤歧義列名'狀態'。當我使用像這樣ApproveType.ApproveID ='批准'然後它顯示錯誤轉換varchar值'Approve'到數據類型int轉換失敗int – user2931015