Error messages displayed when carrying out particular routines such as receiving goods on a purchase order or posting an invoice.
Advisory messages when attempting to delete stock items or warehouses, stating they cannot be removed as they are in use but do not believe this to be the case.
Locating a particular field or table in the database that holds information required for customisation work, for example, creating custom reports.
NOTE: This guide has been put together as a tool to assist you when troubleshooting an issue with the Sage 200 Suite. We do not offer support within Microsoft SQL Management Studio as queries regarding the managing and maintenance of your databases should be dealt with by a database administrator (DBA) or developer. Any additional tools referenced in this guide are given as examples only, there are not provided by nor endorsed by Sage.
If you have been advised to use SQL Profiler to help investigate an issue, this guide will help you to obtain additional information about the cause of the problem or provide the additional information you are looking for to assist with your query. If you are unable to use the results to progress your query, you should contact your database administrator for further assistance.
NOTE: This article has been written based on the assumption that Microsoft SQL Server 2012 is being used. The steps for other versions of the software may differ slightly from those listed below.
and press F5 or select Execute.

button to stop the trace and then the
button to clear the results.You have now prepared SQL Profiler in readiness for monitoring the database activity when you replicate the actions you wish to investigate within Sage 200.
Replicate the steps in Sage 200
At this stage, you should start the trace running again by selecting the
button from the toolbar and then replicate the issue/actions you wish to investigate. When you have finished, select the
button.
TIP: Try to start and stop the trace file as quickly as possible before and after replicating. This will ensure you have less activity to monitor in the trace file. You may wish to use the below scenario as an example as to how best to run a trace on the database.
Example
In this example, we are trying to delete what we believe is an unused stock item. The item has no quantity in stock, is not allocated to an order or associated with a bill of material and the item has never been used on a sales or purchase order. The system advises however that the item cannot be deleted.
SQL Profiler will therefore be able to assist us in showing all statements carried out on the database. The results can then be reviewed and will hopefully show us which of the above criteria is actually stopping the stock item from being deleted.
To run the trace
In this scenario, the advisory message appears the moment we select the stock code we wish to delete. Therefore, we must ensure the trace is running before we select the code. Within Sage 200, the Delete Stock Item screen should be launched before starting the trace to minimise on the unnecessary output. So to run the trace, the steps would be as follows...
- In Sage 200, select Stock Control > Stock Records > Delete Stock Item.
- In SQL Profiler, start the trace by selecting the
button.
- In Sage 200 and the Delete Stock Item window, type the stock code and press Tab or select it from the drop-down list. The Deletion Status should then appear.
- Stop the trace in SQL Profiler by selecting the
button.
You should now have a trace output in SQL Profiler. Click 'View Screenshot' below to view the output from the trace file created in the example in the previous section.

You should look through the list of statements ran (in the TextData column) and use them to try and identify which results may be preventing you from carrying out the action you're trying to complete in the software. To check the results of the various statements, copy and paste the text from the bottom panel in SQL Profiler to a new query in Management Studio. Executing the query will return the same result that the program receives when you receive your error/advisory message in the program.
Solution to example
The example scenario involves trying to delete a stock item but the program advises that it's in use. This could be due to stock allocation, an order, a return or a bill of materials.
The trace file shows activity which backs this up, i.e.. the program is checking tables related to stock (WarehouseItem, BinItem), bill of materials (BomBuildProduct, BomComponentLine), sales orders (SOPStandardItemLink) and purchase orders (POPStandardItemLink). Therefore, we can run these queries in Management Studio and use the results to find where the stock item is being used.
The extract below shows the query that is ran when the POPStandardItemLink table is checked. See screenshot below...
Copy the entire text from the bottom window to the clipboard and paste it into a new query in Management Studio and click Execute. See screenshot below...
We can see now that this item appears to be on purchase order number 3285. Searching for this order in the program confirms this to be the case.
The order would need to be archived/deleted before the stock item could also be deleted.
Use the following tips as a guide to help you when reviewing the trace file...
If you are still unable to discover the information you're looking for, you can save the trace file as a .trc file via the File > Save As > Trace File... menu option and have the file to hand should you wish to contact Technical Support.
If you're unable to find the help you require from our online resources, log a new case with us without having to use phone or email. Simply select 'Manage your cases' from the dashboard or visit my.sage.co.uk/cases.
Upgrade your licence
Growing business? Add more companies, users, or employees to your licence with ease. Leave your details and we’ll be in touch.
