spREINT_GetClientUsersInfo

Parameters

Parameter Parameter Type Mode Description
@MaxRecords int IN
@DownloadStartpoint nvarchar(50) IN
@LastID int IN

Definition

Copy

            CREATE  PROCEDURE [dbo].[spREINT_GetClientUsersInfo]
            (
            @MaxRecords int,
            @DownloadStartpoint nvarchar(50),
            @LastID as int
            )
            AS
            --sterling CR303820-070108
            --changed to LEFT JOINS to include users who have been deleted and no longer have a BackOfficeUsers record
            --the fact they have been deleted needs to be communicated to RE
            BEGIN
                DECLARE @Temp Table(ID int, BackOfficeID int, UserName nvarchar(50), DateAdded datetime, DateLastLogin datetime, Active bit, Deleted bit, UpdateDate datetime)
                If @MaxRecords > 0 SET ROWCOUNT @MaxRecords            

                SELECT CU.ID,
                isnull(BOSP.BackOfficeRecordID, 0) AS "BackOfficeID",
                CU.UserName,
                CU.CreateDate As "DateAdded",
                CU.DateLastLogin,
                CU.Active,
                CU.Deleted,
                CU.UpdateDate,
                CU.LinkedInProfileID,
                C.LinkedInPhoneType 
                FROM dbo.Clients C, dbo.ClientUsers CU 
                LEFT JOIN dbo.backofficesystemusers BOSU ON CU.ID = BOSU.ClientUsersID
                LEFT JOIN dbo.backofficesystempeople BOSP ON BOSU.BackOfficePeopleID = BOSP.ID
                WHERE 
                isnull(BOSP.BackOfficeSystemId, 0) = 0
                AND (CU.UpdateDate > @DownloadStartpoint) or (CU.UpdateDate = @DownloadStartPoint and CU.id > @LastID)
                ORDER BY CU.UpdateDate, CU.ID
                SET ROWCOUNT 0
            END