Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Now again since I do not know the exact schema of all you tables I am only guessing on that your <code>Users table</code> has a field for <code>DesignID</code>, I have Created a Variable <code>@ApprovedBy</code> in your procedure, now if you want to get all the approved documents from a certain level of people all you need to do is pass the <code>Designation</code> as a Parameter to your procedure and it will pull out all the documents approved by that level of employees.</p> <p>Also check the spelling of Users Table as you have used Userss with double s not sure if this is really the case or you misspelled it. </p> <pre><code>ALTER PROCEDURE [dbo].[ALLDOCUMNETS] @ApprovedBy VARCHAR(50) AS BEGIN SET NOCOUNT ON; SELECT DocumentInfo.DocID as DocumentID, dbo.DocumentInfo.DocName as DocumentName, dbo.DocumentInfo.Uploadfile as FileUploaded, dbo.DocumentInfo.UploadedBy as UploadedBy, dbo.Userss.Email as UserEmail, dbo.DocType.DocType as Document, dbo.Department.DepType as Department , dbo.Approval.AppoveBy, dbo.ApproveType.ApproveType as Status FROM dbo.Department INNER JOIN dbo.DocumentInfo ON dbo.DocumentInfo.DepID = dbo.Department.DepID INNER JOIN dbo.DocType ON dbo.DocumentInfo.DocTypeID = dbo.DocType.DocTypeID INNER JOIN dbo.Userss ON Userss.UserName =dbo.DocumentInfo.UploadedBy INNER JOIN dbo.Approval ON dbo.DocumentInfo.DocID = dbo.Approval.DocID INNER JOIN dbo.ApproveType ON dbo.Approval.ApproveID = dbo.ApproveType.ApproveID LEFT JOIN Designation ON dbo.Userss.DesigID=dbo.Designation.DesigID WHERE designation.DesigType = 'Manager' AND dbo.ApproveType.ApproveType = 'Approve' AND dbo.Approval.AppoveBy IN (SELECT UserName FROM Userss.UserName INNER JOIN designation ON Userss.DesignID = designation.DesignID WHERE designation.DesigType = @ApprovedBy) END </code></pre> <p><strong>Calling the Proc</strong></p> <p>to get all the documents approved by a manager just do something like ...</p> <pre><code> EXECUTE dbo.ALLDOCUMNETS @ApprovedBy = 'Manager' </code></pre> <p>to get all the documents approved by a Supervisor just do something like ...</p> <pre><code> EXECUTE dbo.ALLDOCUMNETS @ApprovedBy = 'Supervisor' </code></pre> <p>and so on.....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload