SQL query need to edit

TechUST 601 Reputation points
2023-01-18T15:56:19.7466667+00:00

Hi Expert,

Can you please help to edit below SQL query since i need username instead of device name.

select v_r_system.name0, Add_Remove_Programs_64_DATA.DisplayName00

 

from Add_Remove_Programs_64_DATA

 

inner join v_r_system on v_r_system.resourceid=Add_Remove_Programs_64_DATA.machineid

 

where

 

--Add_Remove_Programs_64_DATA.Publisher00 like '%microsoft%' and

 

Add_Remove_Programs_64_DATA.DisplayName00='Microsoft Visio - en-us'

Microsoft Security | Intune | Configuration Manager | Other
{count} votes

4 answers

Sort by: Most helpful
  1. AllenLiu-MSFT 49,311 Reputation points Microsoft External Staff
    2023-01-20T02:23:04.51+00:00

    Hi, @TechUST

    Thank you for posting in Microsoft Q&A forum.

    Sorry I just saw this post, I edit the sql query for you:

    select v_GS_SYSTEM_CONSOLE_USAGE.TopConsoleUser0, Add_Remove_Programs_64_DATA.DisplayName00
    
    from Add_Remove_Programs_64_DATA
    
    inner join v_r_system on v_r_system.resourceid=Add_Remove_Programs_64_DATA.machineid
    
    inner join v_GS_SYSTEM_CONSOLE_USAGE on v_GS_SYSTEM_CONSOLE_USAGE.ResourceID=v_r_system.resourceid
    
    where
    
    --Add_Remove_Programs_64_DATA.Publisher00 like '%microsoft%' and
    
    Add_Remove_Programs_64_DATA.DisplayName00='Microsoft Visio - en-us'
    
    

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Add comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Garth Jones 1,366 Reputation points
    2023-01-20T02:55:18.5766667+00:00

    Keep in mind it is not supported to query the sql tables directly as you have posted. Only use the supported sql views.

    [https://learn.microsoft.com/en-us/mem/configmgr/develop/core/understand/sqlviews/sql-server-views-configuration-manager

    0 comments No comments

  3. Seyedmajid Taheri 46 Reputation points
    2023-01-26T05:17:36.6766667+00:00

    Hi @TechUST

    select v_R_System.User_Name0, v_GS_ADD_REMOVE_PROGRAMS_64.DisplayName0 
    from v_R_System join v_GS_ADD_REMOVE_PROGRAMS_64 on v_R_System.ResourceID=v_GS_ADD_REMOVE_PROGRAMS_64.ResourceID
    where v_GS_ADD_REMOVE_PROGRAMS_64.DisplayName0 like '%Microsoft visio%'
    
    
    0 comments No comments

  4. AllenLiu-MSFT 49,311 Reputation points Microsoft External Staff
    2023-01-27T08:45:36.88+00:00

    Hi, @TechUST

    I replaced the table(Add_Remove_Programs_64_DATA) with view(v_Add_Remove_Programs) followed Garth's suggestion.

    If there any assistance we can provide, feel free to let us know.

    select v_GS_SYSTEM_CONSOLE_USAGE.TopConsoleUser0, v_Add_Remove_Programs.DisplayName0
    
    from v_Add_Remove_Programs
    
    inner join v_r_system on v_r_system.resourceid=v_Add_Remove_Programs.ResourceID
    
    inner join v_GS_SYSTEM_CONSOLE_USAGE on v_GS_SYSTEM_CONSOLE_USAGE.ResourceID=v_r_system.resourceid
    
    where
    
    --Add_Remove_Programs_64_DATA.Publisher00 like '%microsoft%' and
    
    v_Add_Remove_Programs.DisplayName0='Microsoft Visio - en-us'
    
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.