You may receive the following error when running a ConfigMgr report query from SQL Server Management Studio:

Error

Msg 137, Level 15, State 2, Line 16
Must declare the scalar variable "@UserSIDs".

 

To resolve this issue, simply place the following declare statement at the beginning of your query:

Declare @UserSIDs As Varchar(25); Set @UserSIDs = 'Disabled'

 

Before                

SELECT DISTINCT
  dp.ServerName AS C070,
     sys.SiteCode,
        dp.SiteName as SN,
        dp.HasRelationship as DpGroupMember,
        dp.GroupCount as CountOfGroupMembership,
        dp.IsProtected as AllowFallback,
        dp.PreStagingAllowed as Prestaging,
        dp.IsPxe as PXE,
        dp.IsMulticast as Multicast,
        dp.HealthCheckEnabled as ContentValidation,
        dp.AddressScheduleEnabled as DpSchedule,
        case when dp.Communication = 1 then 'HTTPS' else 'HTTP' end as Comm,
        dp.InternetFacing as Internet,
        dp.RateLimitsEnabled as RateLim
from fn_rbac_SystemResourceList(@UserSIDs)  as sys
join fn_rbac_DistributionPointInfo(@UserSIDs)  as dp
on sys.NALPath = dp.NALPath
where sys.RoleName = 'SMS Distribution Point'

Msg 137, Level 15, State 2, Line 16
Must declare the scalar variable "@UserSIDs". 

 

AFTER

Declare @UserSIDs As Varchar(25); Set @UserSIDs = 'Disabled'

SELECT DISTINCT
  dp.ServerName AS C070,
     sys.SiteCode,
        dp.SiteName as SN,
        dp.HasRelationship as DpGroupMember,
        dp.GroupCount as CountOfGroupMembership,
        dp.IsProtected as AllowFallback,
        dp.PreStagingAllowed as Prestaging,
        dp.IsPxe as PXE,
        dp.IsMulticast as Multicast,
        dp.HealthCheckEnabled as ContentValidation,
        dp.AddressScheduleEnabled as DpSchedule,
        case when dp.Communication = 1 then 'HTTPS' else 'HTTP' end as Comm,
        dp.InternetFacing as Internet,
        dp.RateLimitsEnabled as RateLim
from fn_rbac_SystemResourceList(@UserSIDs)  as sys
join fn_rbac_DistributionPointInfo(@UserSIDs)  as dp
on sys.NALPath = dp.NALPath
where sys.RoleName = 'SMS Distribution Point'