SQL
USE [PrintMonitor]
GO
/****** Object:  StoredProcedure [dbo].[Get_Printed_Documents_For_User]    Script Date: 10/15/2008 20:50:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Get_Printed_Documents_For_User]
     (
     @Username varchar(255)
     )
/* -- [Get_Printed_Documents_For_User]------------------------------------------------
 * Returns the list of documents from the view [PRINTED DOCUMENTS] according to the
 * passed-in user name's permissions
 */
 AS
     BEGIN
                     SELECT a.[User Name],
                            a.[Document Name],
                            a.Submitted,
                            a.[Printer Name],
                    a.[Machine Name] ,
                    a.Pages,
                    a.[Pages Printed],
                    a.[Paper Type],
                    a.Width,
                    a.Height,
                    a.[Measurement Units]
            FROM dbo.[PRINTED DOCUMENTS] a,
                 dbo.[User Permissions] b
            WHERE b.[User Name] = @Username
              AND
                 (
                   A.[User Name] = b.[User name]
                 OR
                   b.[Can View All Users] = 1
                 )


     RETURN
     END

Last edited Oct 15, 2008 at 7:51 PM by Merrion, version 1

Comments

No comments yet.