johnli Posted May 13, 2016 Report post Posted May 13, 2016 Hi! How can i build a query based on a IP sunnet ? Address: 159.171.10.1 Netmask: 255.255.255.128 = 25 Network: 159.171.10.0/25 Broadcast: 159.171.10.127 HostMin: 159.171.10.1 HostMax: 159.171.10.126 I have now (but it won't do the job) : select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_NETWORK_ADAPTER_CONFIGURATION on SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.ResourceId = SMS_R_System.ResourceId where SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.IPAddress >= "159.171.10.1" and SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.IPAddress <= "159.171.10.126" Any tips, ideas ?? Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted May 13, 2016 Report post Posted May 13, 2016 The IP address is a String and not a Number therefore the >= and <= will treat everything as a string. This will produce odd results. For this I would try to look at the gateway, instead of the IP address.. Quote Share this post Link to post Share on other sites More sharing options...
Garrett804 Posted May 13, 2016 Report post Posted May 13, 2016 this is what I use for my subnet based collections. select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.IPSubnets in ("10.0.1.0") and SMS_R_System.OperatingSystemNameandVersion like "%workstation%" Quote Share this post Link to post Share on other sites More sharing options...
johnli Posted May 18, 2016 Report post Posted May 18, 2016 The IP address is a String and not a Number therefore the >= and <= will treat everything as a string. This will produce odd results. For this I would try to look at the gateway, instead of the IP address.. oke, I give it a try! Thanks... Quote Share this post Link to post Share on other sites More sharing options...
johnli Posted May 18, 2016 Report post Posted May 18, 2016 this is what I use for my subnet based collections. select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.IPSubnets in ("10.0.1.0") and SMS_R_System.OperatingSystemNameandVersion like "%workstation%" I must test this....thanks ! Quote Share this post Link to post Share on other sites More sharing options...
Shameer K Posted May 12, 2022 Report post Posted May 12, 2022 select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.IPSubnets in ("xx.xx.xx.0") and SMS_R_System.OperatingSystemNameandVersion like "%workstation%" This is working thank you Quote Share this post Link to post Share on other sites More sharing options...