Management Center SQL script (English)

Script for changing sharenames
in the Management Center database
Technical Information
ThinPrint GmbH
Alt-Moabit 91 a
10559 Berlin
Germany / Alemania
Cortado, Inc.
7600 Grandview Avenue
Suite 200
Denver, Colorado 80002
USA / EEUU
Cortado Pty. Ltd.
Level 20, The Zenith Centre,
Tower A
821 Pacific Highway
Chatswood, NSW 2067
Australia
E-Mail: [email protected]
Web: www.thinprint.com
Issued: April 8, 2015 (v04)
Purpose of the sharename SQL script
– In the Management Center console’s CONNECTION¡ EDIT PRINTERS screen, the
Output Gateway printer objects are automatically appended a sharename, in
the format:
printername_localprintserver or clientprintername_clientaddress
However, some customers want to remove the _localprintserver or _clientaddress
from the sharename, but prefer not to do this manually.
Note! It is important that neither the local printserver name nor the client address not
contains an underscore (_). This is because the script searches (in the sharename)
for the first underscore from the right. Alternatively, if, for example, all client
addresses on the same connection contain an underscore, the script can be run twice
using the connection ID (see below).
Change all sharenames in an SQL database
1. In the Management Center console, find out the database name with
EXTRA¡ APPLICATION SETTINGS.
2. Close the Management Center console.
3. Open SQL Server Management Studio.
4. Mark the database (on the left) and perform a backup with TASKS¡ BACK UP in
the context menu.
5. Then click NEW QUERY (left arrow in Illus. 1).
Illus. 1
Illus. 1
Script for changing the sharenames of all printers
UPDATE CONPRINTER SET SHARENAME = SUBSTRING(SHARENAME,
1, LEN(SHARENAME) - CHARINDEX('_', REVERSE(SHARENAME))
)
2
Technical information
MC-SQL-script_e.fm
© ThinPrint GmbH 2015
6. Copy the following string into the right input field:
7. Click EXECUTE (right arrow in Illus. 1). A confirmation message will appear
below (Illus. 2); in this message the number of rows is double the number of
printer objects.
8. Close SQL Server Management Studio.
9. Finished. Re-open the Management Center console.
Illus. 2
Illus. 2
Confirmation message (example)
Change sharenames of specific connections
As an alternative to running the script on the entire database, it's also possible to run
it on only a specified Management Center Connection. In addition to the steps above,
you must identify the relevant Connection ID beforehand (see the column FK_CONNECTION in Illus. 4). To do so, mark the row of the Connection printers dbo.CONPRINTER and choose SELECT TOP 1000 ROWS or EDIT TOP 200 ROWS (Illus. 3).
Illus. 3
Opening the table dbo.CONPRINTER
© ThinPrint GmbH 2015
Illus. 3
MC-SQL-script_e.fm
Technical information
3
Illus. 4
Illus. 4
Checking the IDs in FK_CONNECTION or FK_SRCPRINTER (example)
– At this point, you may receive a “not accessible” message (Illus. 5). If so, temporarily change the database property Restrict Access from Single_User to Multi_User (Illus. 6).
Illus. 5
Illus. 5
Not accessible message
© ThinPrint GmbH 2015
4
Technical information
MC-SQL-script_e.fm
Illus. 6
Illus. 6
Changing the Restrict Access property temporarily
– Then copy the following string into the input field on the right:
UPDATE CONPRINTER SET SHARENAME = SUBSTRING(SHARENAME,
1, LEN(SHARENAME) - CHARINDEX('_', REVERSE(SHARENAME))
) WHERE FK_CONNECTION = 4;
At the end of this script, enter the identified Connection ID – in this case, 4 –
in front of the semicolon (Illus. 7).
Illus. 7
Illus. 7
Script for changing the sharenames of Connection with ID 4
© ThinPrint GmbH 2015
– Click EXECUTE (right arrow in Illus. 1). A confirmation message will appear
below (Illus. 2); in this message the number of rows is double the number of
printer objects.
– Set the database property Restrict Access back to Single_User and close
SQL Server Management Studio.
MC-SQL-script_e.fm
Technical information
5
Change sharenames of specific printers
As part of other scripts it can be necessary to change sharenames only of single
printers. So, alternatively to the use per Connection the script can be run per printer.
Here, check the IDs of the relevant printers before (see the column FK_SRCPRINTER
in Illus. 4).
– On this, maybe you get a “not accessible” message (Illus. 5). In this case
change the database Restrict Access property from Singe_User to Multi_User
temporarily (Illus. 6).
– Then copy the following String into the right input field:
UPDATE CONPRINTER SET SHARENAME = SUBSTRING(SHARENAME,
1, LEN(SHARENAME) - CHARINDEX('_', REVERSE(SHARENAME))
) WHERE FK_SRCPRINTER = 15;
Enter the identified Printer ID at the end of this script – here: 15 – just before
the semicolon.
– Click EXECUTE (right arrow in Illus. 1). A confirmation message will appear
below (Illus. 2); in this message the number of rows is twice as big as the number of printer objects.
– Set the database Restrict Access property back to Singe_User and close
SQL Server Management Studio.
© ThinPrint GmbH 2015
6
Technical information
MC-SQL-script_e.fm