Security Hint:
- Always do a database backup before you do any changes to the regarding database.
Prerequisites:
- Download the attached "DuplicateCleanup.zip" file and extract the included files.
- Microsoft SQL Management Studio with access to the RayManageSoft/RayVentory database
- Microsoft Excel 2010 or newer version
- SQL Server 2012 or newer
- If you are using a RayManageSoft version older than 11.0 you also need to execute the attached "create_new_RMS_func.sql" file in the ManageSoft database (execute multiple times if errors are shown)
Creating a database backup
- Start Microsoft SQL Management Studio with elevated rights and connect to the RayManageSoft/RayVentory database.
- Open the "Backup.txt" file and copy the SQL-Code into a new Sql-Query in Microsoft SQL Management Studio.
- Validate that the path in line 5 exists on the machine, where the database is located.
- Validate that the database name in line 6 matches.
- Execute the adjusted SQL-Query in Microsoft SQL Management Studio. This will create a backup of your RayManageSoft/RayVentory database. The file "managesoft_backup.bak" will be created.
Show Duplicates
- Open the "Duplicate_Show.txt" file and copy the SQL-Code into a new query in Microsoft SQL Management Studio.
- By default inventories that are older than 89 days are regarded as outdated. This value can be changed in line 24: when DATEDIFF(day,GetDate(),InventoryReport.SWDate) * -1 > 89 then 'TRUE' Just change the value of 89 to the desired value.
- Make sure that ManageSoft is selected as the current database in the drop-down list at the top left
- Execute the query, to get a list of potential duplicates.
- Click on the top left cell of the results table to mark the whole table
- Do a right click in your results view and click on "Copy with headers".
- Open the file called "DuplicateAnalysis_Template.xlsx".
- Select cell A7 in the table and paste the previously copied content into the document.
- Check each entry carefully and decide whether the device inventory is a duplicate and should get removed or it is not a duplicate and should be kept. To do so, in the column "Recommendation" you have the possibility to select "Delete Inventory" for each device.
- For every entry with "Confirm Keep/Delete inventory" you have to decide if you want to keep or delete it.
- Save and export as CSV (CSV UTF-8 (seperated by separators) (*.csv))
- Open the exported CSV file in Notepad++ or a similar text editor.
- Remove all unnecessary characters before the header begins and at the bottom of the file, like in the example picture below.
- Save the file as "DuplicateList.csv"
Remove Duplicates
For SSMS 17.3 or newer:
- Start Microsoft SQL Management Studio with administrative rights and connect to the RayManageSoft/RayVentory database.
- Right click on your ManageSoft database and click "Tasks" -> "Import Flatfile..."
- Press "Next >"
- Select the adjusted .csv file of "Show Duplicates" step 14.
- Enter the name of the new table "DuplicateList" and click on "Next >".
- Click on the "Next >" button 2 more times.
- Click on "Finish" and validate that the result was successful.
- Open the attached file called "Duplicate_Delete.txt" and copy the content into a new SQL-Query in Microsoft SQL Server Management Studio.
- Execute the SQL-Query to delete the computers out of the ManageSoft database which are explicitly marked as "Delete Inventory" by you.
- To delete the temporary table we created in "Remove Duplicates" step 7, you have to open a new SQL-Query, paste "DROP TABLE [dbo].[DuplicateList]" and execute.
- If you want to check whether you still have duplicates, repeat all steps.
For SSMS versions below 17.3:
- Start Microsoft SQL Management Studio with administrative rights and connect to the RayManageSoft/RayVentory database.
- Right click on your ManageSoft database and click "Tasks" -> "Import Data..."
- Press "Next >"
- Select "Flat File Source" as Data source
- Select the adjusted .csv file of "Show Duplicates" step 14.
- Click "Next >" until the "Choose a Destination" page is opened
- Select the "SQL Server Native Client 11.0" from the dropdown list and hit next
- Click "Next >" 3 more times and then click "Finish" and validate that the result was successful
- Open the attached file called "Duplicate_Delete.txt" and copy the content into a new SQL-Query in Microsoft SQL Server Management Studio.
- Execute the SQL-Query to delete the computers out of the ManageSoft database which are explicitly marked as "Delete Inventory" by you.
- To delete the temporary table we created in "Remove Duplicates" step 8, you have to open a new SQL-Query, paste "DROP TABLE [dbo].[DuplicateList]" and execute.
- If you want to check whether you still have duplicates, repeat all steps.
Comments