USP_SEARCHLIST_CMSUSERSEARCH

Returns list of CMS Users to link to AppUsers

Parameters

Parameter Parameter Type Mode Description
@LASTNAME nvarchar(50) IN Last name
@FIRSTNAME nvarchar(50) IN First name
@USERNAME nvarchar(50) IN User name
@MAXROWS smallint IN Input parameter indicating the maximum number of rows to return.

Definition

Copy


CREATE procedure dbo.USP_SEARCHLIST_CMSUSERSEARCH
(
    @LASTNAME nvarchar(50) = null,
  @FIRSTNAME nvarchar(50) = null,
    @USERNAME nvarchar(50) = null,
    @MAXROWS smallint  = 500
)
as


  set @LASTNAME = COALESCE(@LASTNAME,'') + '%' ;
  set @FIRSTNAME = COALESCE(@FIRSTNAME,'') + '%' ;
  set @USERNAME = COALESCE(@USERNAME,'') + '%' ;

SELECT top(@MAXROWS)
  GUID as ID,
  USERNAME,
  FIRSTNAME,
  LASTNAME
FROM
  dbo.CLIENTUSERS 
WHERE
  ACTIVE = 1
  AND 
  DELETED = 0 
  AND
  ((@FIRSTNAME is null) or (FIRSTNAME LIKE @FIRSTNAME))
  and ((@LASTNAME is null) or (LASTNAME LIKE @LASTNAME))
  and ((@USERNAME is null) or (USERNAME LIKE @USERNAME))
  order by USERNAME