EA7_spLookupBBNCUsers

Parameters

Parameter Parameter Type Mode Description
@lastname nvarchar(50) IN
@firstname nvarchar(50) IN

Definition

Copy

            CREATE PROC [dbo].[EA7_spLookupBBNCUsers]( @lastname nvarchar(50), @firstname nvarchar(50) )
            AS BEGIN
                SET nocount on
                select DISTINCT a.id, a.lastname, a.firstname, a.username, a.datelastlogin from dbo.clientusers a 
                where 
                ( 
                    ((len(@lastname) = 0 and len(@firstname) = 0) and (a.lastname = '' and a.firstname = '')) OR 
                    ((len(@lastname) = 0 and len(@firstname) > 0) and (a.firstname like @firstname+'%')) OR 
                    ((len(@lastname) > 0 and len(@firstname) = 0) and (a.lastname like @lastname+'%')) OR 
                    ((len(@lastname) > 0 and len(@firstname) > 0) and (a.lastname like @lastname+'%' and a.firstname like @firstname+'%'))
                )
                AND a.internaluser <> 1 AND a.[deleted] = 0 AND a.[active] = 1 
                AND a.id NOT IN (
                    select b.clientusersid from dbo.backofficesystemusers b 
                    inner join dbo.backofficesystempeople c on c.id = b.backofficepeopleid 
                    where b.[current] = 1 and c.BackOfficeSystemID = 1)
                order by a.lastname
            END