cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
375
Views
0
Helpful
2
Replies

CM SQL query

johutchins
Level 1
Level 1

Hi,

I'm upgrading from a 3.2 server to a clean 4.0 server. The current server started out as a pilot and has about 50 phones on it.

When the new 4.0 system is in place, it will have about 200 phones. I was hoping to avoid upgrading the existing 3.2 server, mainly to save time, and I was hoping to extract the MAC and Device Description so I can BAT in the existing phones with the new phones.

I poked around found that the Device table seems to have what I need, but it does not seem to indicate the phone type (7910, 7940, etc).

Any suggestions?

Thanks,

--Jon

2 Replies 2

aaronw.ca
Level 5
Level 5

You are right, the device table has what you need. The name field in the device table indicates the MAC address/hostname of the phone, while the tkProduct and tkModel provide more information on what type and model of device each row describes. tkClass describes the general category (ie gateway, phone, etc) of the device. The foreign key is stored in the device table, which links to another table.

When you see a table prefixed by "tk", that field is a link to a "type table". replace "tk" with "type" and look for that table in the database. For example, when you see tkProduct, look for a table called typeProduct. The value in the "tk" field links to the enum field in the type table, and you can then look up a description in the type table (ie name). The fk naming convention follows a similar pattern, except you simply drop the "fk" from the field name and look for a similar table (for example, for fkDevicePool look for a table named DevicePool, and match the value of fkDevicePool to the pkid value in the fkDevicePool field of the originating table.

Enough tech-talk: Try a query like the following:

SELECT DEVICE.name as DeviceName, DEVICE.description as DeviceDescription,

TYPEMODEL.name as DeviceModel, TYPEPRODUCT.name as DeviceProduct,

TYPECLASS.name as DeviceClass

FROM DEVICE, TYPEMODEL, TYPEPRODUCT, TYPECLASS

WHERE DEVICE.tkModel = TYPEMODEL.enum

AND DEVICE.tkProduct = TYPEPRODUCT.enum

AND DEVICE.tkClass = TYPECLASS.enum

ORDER BY DEVICE.tkClass, DEVICE.tkModel

which is taken from this thread:

http://forum.cisco.com/eforum/servlet/NetProf?page=netprof&CommCmd=MB%3Fcmd%3Ddisplay_location%26location%3D.1dd61323

You don't actually have to link the tables.. you can just filter for specific values in the tk fields once you know what values to look for in the device table.

Thanks, I'll give it a go.

--Jon