Renaming printers
I am currently re-hosting from Win 2003 to Win 2012R2 and because a number of printers are actually attached to workstations the printer names change (typically from PRNT1-R2 to \\workstation\PRNT1-R2). It turns out that we have 57 instances that need changing, and since I have to do the changes each time we update the new system (1.8 on Win2012) from the production system (1.7 on Win2003), I wrote some sql to do the renames.
It is below. The first query just shows you what the status is - change the last line to change which printers are show. The rest are used to do the renames.
Execute the "SET SQL_SAFE_UPDATES=0;" first, then edit the old and new names and execute their sets, then execute the update. Repeat for each printer to be renamed, then finally execute the "SET SQL_SAFE_UPDATES=1;"
Regards, Tim G
select er.description, ed.value, e.name, e.arch_short_name
from entity_relationships er
join entity_relationship_details ed on ed.entity_relationship_id = er.entity_relationship_id
and ed.name = 'printerName'
join entities e on e.entity_id = er.target_id
where er.arch_short_name = 'entityRelationship.documentTemplatePrinter'
and ed.value like '%label%';
SET SQL_SAFE_UPDATES=0;
set @oldname = 'LABEL-R2';
set @newname = '\\\\192.168.1.142\\LABEL-R2';
update entity_relationships er, entity_relationship_details ed
set ed.value = @newname, er.description = @newname
where ed.entity_relationship_id = er.entity_relationship_id
and er.arch_short_name = 'entityRelationship.documentTemplatePrinter'
and ed.name = 'printerName'
and ed.value = @oldname;
SET SQL_SAFE_UPDATES=1;