Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dtorgy
Starting Member
2 Posts |
Posted - 2005-10-11 : 17:10:58
|
| Ok, I have a table with IP addresses stored in decimal format using both positive and negative numbers.The way that they are stored is:Positve1 thru 2147483647 = 0.0.0.1 - 127.255.255.255Negative-2147483648 thru -1 = 128.0.0.0 - 255.255.255.255Conversionpositivex/2^24 . (x/2^24)/2^16 . etc . etcnegative(x+2^32)/2^24 . ((x+2^32)/2^24)/2^16 . etc . etcI have a script which works by using UNION and the WHERE statements are x>0 x<0My problem is I need to use a 3rd party app to run the script (McAfee ePO). McAfee does not recognize the UNION. My question is, can I acheive the same results as the script below, without using UNION.SELECT ReportFullPathNode.FullPathName,cast(cast(IPSubnetMask.IP_Start as bigint)/16777216 as varchar) + '.' +cast(cast(IPSubnetMask.IP_Start as bigint)%16777216/65536 as varchar) + '.' +cast(cast(IPSubnetMask.IP_Start as bigint)%16777216%65536/256 as varchar) + '.' +cast(cast(IPSubnetMask.IP_Start as bigint)%16777216%65536%256 as varchar),cast(cast(IPSubnetMask.IP_End as bigint)/16777216 as varchar) + '.' +cast(cast(IPSubnetMask.IP_End as bigint)%16777216/65536 as varchar) + '.' +cast(cast(IPSubnetMask.IP_End as bigint)%16777216%65536/256 as varchar) + '.' +cast(cast(IPSubnetMask.IP_End as bigint)%16777216%65536%256 as varchar),cast(IPSubnetMask.LeftMostBits as varchar),IPSubnetMask.IP_StartFROM IPSubnetMask, ReportFullPathNode ReportFullPathNodeWHERE IPSubnetMask.IP_Start>0 and IPSubnetMask.ParentID = ReportFullPathNode.LowestNodeIDUNION ALLSELECT ReportFullPathNode.FullPathName,cast(cast(4294967296+IPSubnetMask.IP_Start as bigint)/16777216 as varchar) + '.' +cast(cast(4294967296+IPSubnetMask.IP_Start as bigint)%16777216/65536 as varchar) + '.' +cast(cast(4294967296+IPSubnetMask.IP_Start as bigint)%16777216%65536/256 as varchar) + '.' +cast(cast(4294967296+IPSubnetMask.IP_Start as bigint)%16777216%65536%256 as varchar),cast(cast(4294967296+IPSubnetMask.IP_End as bigint)/16777216 as varchar) + '.' +cast(cast(4294967296+IPSubnetMask.IP_End as bigint)%16777216/65536 as varchar) + '.' +cast(cast(4294967296+IPSubnetMask.IP_End as bigint)%16777216%65536/256 as varchar) + '.' +cast(cast(4294967296+IPSubnetMask.IP_End as bigint)%16777216%65536%256 as varchar),cast(IPSubnetMask.LeftMostBits as varchar),IPSubnetMask.IP_Start+4294967296FROM IPSubnetMask, ReportFullPathNode ReportFullPathNodeWHERE IPSubnetMask.IP_Start<0 and IPSubnetMask.ParentID = ReportFullPathNode.LowestNodeID |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-10-11 : 17:42:39
|
| Put your query into a view, have the software access the view instead. It shouldn't even know there is a UNION if you use a view.Tara |
 |
|
|
dtorgy
Starting Member
2 Posts |
Posted - 2005-10-11 : 18:00:12
|
| That workes perfectly.Thanks,David T. |
 |
|
|
|
|
|
|
|