Technical FAQs

Ask a Question

SQL - Removing Extra Database Logical File Names

Issue:
When performing the resolution in FA210466, a user might notice that the ION_Network database actually contains both the PegasysNOM_Data and ION_Network_Data Logical Names as seen below. Attempting to remove one of the Logical Names results in an error. 





Product Line:
Power Monitoring Expert 
StruxureWare Power Monitoring
ION Enterprise

Environment: 
PME Installer
SQL Server Management Studio

Cause: 
The error occurs because the ION_Network database is actually split across multiple MDF files. This is a result of a pre-ION Enterprise 5.0 database having been upgraded numerous times to newer versions. 

Resolution:
*Warning: Irreparable database damage can occur. This procedure should only be performed by users familiar with SQL Server Management Studio. Databases should be backed up prior to performing this procedure.* 


In order to remove the extra database files and allow us to properly name the Logical Files as ION_Network_Data and ION_Network_Log, we need to merge the contents from one into the other. 

1) First we need to determine which of the two is the main MDF file. To do this, run the following query in SQL Server Management Studio. 

sp_helpdb ION_Network
go


The result should be something similar to this:


The result of the query shows that the PegasysNOM_Data and PegasysNOM_Log are the main files for the database. Therefore we will merge the ION_Network_Data and ION_Network_Log files into those, and then remove them. Once removed, we can rename the PegasysNOM files to ION_Network as described in FA210466. 

2) To do this, run the following query.

USE ION_Network; 
DBCC SHRINKFILE ('ION_Network_Data', EMPTYFILE); 
ALTER DATABASE ION_Network REMOVE FILE ION_Network_Data;

USE ION_Network; 
DBCC SHRINKFILE ('ION_Network_Log', EMPTYFILE); 
ALTER DATABASE ION_Network REMOVE FILE ION_Network_Log;


3) Once the query has completed, we will be left with just the PegasysNOM_Data and PegasysNOM_Log files. Re-name these files to ION_Network_Data and ION_Network_Log. 
 
Was this helpful?
What can we do to improve the information ?