[dbo].[BIUserInformation]
CREATE PROCEDURE [dbo].[BIUserInformation]
as
set nocount on
if( exists( select top 1 1 from INFORMATION_SCHEMA.VIEWS where TABLE_SCHEMA = N'hReports' and TABLE_NAME = N'BIUserInformation' ) )
begin
select *
from hReports.BIUserInformation
end
else
begin
select
UserID = UserAccess.UserID,
UserName = dbo.FormatLastNameFirstName( SysUser.LASTNAME, SysUser.FIRSTNAME ),
UserStatus = [Status].[Status],
LoginID = convert( nvarchar(50), null ),
[Role] = convert( nvarchar(50), null ),
LastLogin = convert( datetime2(7), null ),
IsDeletedUser = convert( bit, null ),
UseMoversSuiteCredentials = ReportingUser.UseMoversSuiteCredentials,
IsSuperUser = ReportingUser.IsSuperUser
from ReportingUser
left outer join SysUser on ReportingUser.SysUserFID = SysUser.SysUserId
left outer join UserAccess on SysUser.SysUserId = UserAccess.SysUserId
left outer join [Status] on SysUser.[STATUS] = [Status].PriKey
where isnull( UserAccess.UserID, '' ) != 'msuite'
end
GO
GRANT EXECUTE ON [dbo].[BIUserInformation] TO [MssExec]
GO