find machines with duplicate serial numbers

Author Message
g009

  • Total Posts : 20
  • Scores: 0
  • Reward points : 11100
  • Joined: 9/30/2009
  • Status: offline
find machines with duplicate serial numbers Tuesday, September 18, 2012 10:39 AM (permalink)
0
I have this SQL code to try and find machines that share the same serial number.   when I run this it only retruns 1 record and we know for a fact we have many dups.  We're doing a rollout from XP to Windows 7 so we end up with serial numbers attached to 2 or 3 NetBIOS names.
 
SELECT 
cs.Name0 AS [Computer Name],
rs.User_Name0 AS [User Name],
rs.User_Domain0 AS [Domain],
gs.SerialNumber0 AS [Serial Number]

FROM v_GS_COMPUTER_SYSTEM cs JOIN v_R_System rs ON cs.resourceID = rs.resourceID
JOIN v_GS_PC_BIOS gs ON cs.ResourceID = gs.ResourceID

GROUP BY 
cs.Name0,
rs.User_Name0,
rs.User_Domain0,
gs.SerialNumber0 
HAVING COUNT (cs.Name0) > 1
 
what is this code doing wrong and how to I make it work?  
 
#1
    vigorousgraywolf

    • Total Posts : 2
    • Scores: 0
    • Reward points : 6060
    • Joined: 8/2/2011
    • Status: offline
    Re:find machines with duplicate serial numbers Tuesday, September 18, 2012 11:58 AM (permalink)
    0
    You only need to add the following line:
    COUNT(gs.SerialNumber0) AS NumOccurences
     
    Whole code:
    SELECT 
    cs.Name0 AS [Computer Name],
    rs.User_Name0 AS [User Name],
    rs.User_Domain0 AS [Domain],
    gs.SerialNumber0 AS [Serial Number] ,
    COUNT(gs.SerialNumber0) AS NumOccurences
    FROM v_GS_COMPUTER_SYSTEM cs JOIN v_R_System rs ON cs.resourceID = rs.resourceID
    JOIN v_GS_PC_BIOS gs ON cs.ResourceID = gs.ResourceID
    GROUP BY 
    cs.Name0,
    rs.User_Name0,
    rs.User_Domain0,
    gs.SerialNumber0 
    HAVING COUNT (cs.Name0) > 1
     
     
    #2
      g009

      • Total Posts : 20
      • Scores: 0
      • Reward points : 11100
      • Joined: 9/30/2009
      • Status: offline
      Re:find machines with duplicate serial numbers Tuesday, September 18, 2012 12:09 PM (permalink)
      0
      Thank you.... I ran your code and it only returns 1 row if information.   And we know we have many serial numbers matched up to more than 1 Computer Name.     What else to try?  
       
       
       
      #3
        vigorousgraywolf

        • Total Posts : 2
        • Scores: 0
        • Reward points : 6060
        • Joined: 8/2/2011
        • Status: offline
        Re:find machines with duplicate serial numbers Tuesday, September 18, 2012 4:01 PM (permalink)
        0
        Just to verify - can you run the following query looking for a particular serial number replacing <serial#> with a serial number you know is listed more than once?
         SELECT 
         rs.Name0 AS [Computer Name],
         rs.User_Name0 AS [User Name],
         rs.User_Domain0 AS [Domain],
         gs.SerialNumber0 AS [Serial Number]
        FROM
         v_R_System rs
         JOIN v_GS_PC_BIOS gs ON rs.ResourceID = gs.ResourceID
        WHERE
         gs.SerialNumber0 = '<Serial#>'
         
         
        <message edited by vigorousgraywolf on Tuesday, September 18, 2012 4:09 PM>
        Regards,
        Ian Martin
         
         
        #4
          g009

          • Total Posts : 20
          • Scores: 0
          • Reward points : 11100
          • Joined: 9/30/2009
          • Status: offline
          Re:find machines with duplicate serial numbers Tuesday, September 18, 2012 5:11 PM (permalink)
          0
          Yes, when I enter the serial number from my PC it correctly returned my PC's NetBIOS name.
           
           
           
          #5
            gjones

            • Total Posts : 2291
            • Scores: 136
            • Reward points : 97820
            • Joined: 6/5/2001
            • Location: Ottawa, Ontario, Canada
            • Status: offline
             
            #6
              g009

              • Total Posts : 20
              • Scores: 0
              • Reward points : 11100
              • Joined: 9/30/2009
              • Status: offline
              Re:find machines with duplicate serial numbers Tuesday, September 18, 2012 6:16 PM (permalink)
              0
              Thanks but what does ES_DupSerial.exe actually do?   We can't just install 3rd party tools onto our production SCCM servers.  And if this is a SQL report why an .EXE?  
               
              Thank you.  
               
               
               
              #7
                gjones

                • Total Posts : 2291
                • Scores: 136
                • Reward points : 97820
                • Joined: 6/5/2001
                • Location: Ottawa, Ontario, Canada
                • Status: offline
                Re:find machines with duplicate serial numbers Tuesday, September 18, 2012 8:13 PM (permalink)
                0
                The setup installs the RDL and reset the data source on the RDL to the CM07/CM12 data source.
                 
                When you run  the setup, you can grab the RDL from the %temp% directory and cancel the setup, then manually upload the RDL and reset the DS yourself.
                 
                http://support.enhansoft.com/Blogs/post/How-to-upload-a-report-manually-to-SQL-Server-Reporting-Services-(SSRS).aspx
                http://support.enhansoft.com/Blogs/post/How-to-Change-the-SSRS-Datasource.aspx
                 
                If you have any doubts install it within your lab.
                 
                 
                #8
                  Online Bookmarks Sharing: Share/Bookmark

                  Jump to:

                  Current active users

                  There are 0 members and 1 guests.

                  Icon Legend and Permission

                  • New Messages
                  • No New Messages
                  • Hot Topic w/ New Messages
                  • Hot Topic w/o New Messages
                  • Locked w/ New Messages
                  • Locked w/o New Messages
                  • Read Message
                  • Post New Thread
                  • Reply to message
                  • Post New Poll
                  • Submit Vote
                  • Post reward post
                  • Delete my own posts
                  • Delete my own threads
                  • Rate post

                  2000-2013 ASPPlayground.NET Forum Version 3.9