This provides devices and DNs where the External Phone Number Mask is like 7162010662. The percent sign allows you to allow for an unknown number of characters if you are searching for partial numbers. This sample sorts by device name.
run sql select d.name, d.description, n.dnorpattern, dmap.e164mask from device as d inner join devicenumplanmap as dmap on dmap.fkdevice = d.pkid inner join numplan as n on dmap.fknumplan = n.pkid where dmap.e164mask like '%7162010662' order by d.name
This provides Translation Patterns where the Called Party Transform Mask is starts with 330.
run sql select dnorpattern, calledpartytransformationmask from numplan where tkpatternusage=3 and calledpartytransformationmask like '330%'
This provides CUCM phone Device Name, Description, Model and Phone Load Name configured on device if present:
run sql SELECT d.name AS device, d.description, m.name AS model, d.specialloadinformation AS device_load FROM device d INNER JOIN typemodel m ON d.tkmodel = m.enum WHERE m.tkclass = 1 ORDER BY m.name, d.name;