Reverse Engineer a SQL Profiler Trace

Posted on 2006-10-19
Last Modified: 2008-03-06
I am working with a MSSQL based application that has a COM interface for programming/integration.
If I run a sql trace on the database while entering a record into the application I can clearly see what is going on.
In fact the manufacturer suggests that developers use SQL traces to 'reverse-engineer' the application when
trying to integrate with it.

Here is my current approach:
I take pieces of the sql trace log, visually parse it out, figure out what kind of sql command is being called,
and convert that (in VB) to the appropriate COM calls for the appliations COM object.
The process is a bit tedious.

Does anyone have any suggestions on how to parially automate this process?
I am thinking that I am going to have to write my own parsing logic to parse out the trace log, but just want to be sure
that there is no magic utility out there that already does something similar.

Thanks,  Kevin.
Question by:kevinvw1
  • 3
  • 2
LVL 29

Accepted Solution

Nightman earned 500 total points
Comment Utility
None that I know of.

What I can tell you is that any manufacturer/supplier that told me to run a sql trace to see what is happening internally in their application if I need to integrate to it will be shown the door - this indicates poor system documentation (and therefore possibly poor change management and quality control as well). If they don't have a published SDK, they should at LEAST be able to show some system documentaion!

Author Comment

Comment Utility
Let me explain -

They actually do have decent documentation, but their COM does not enforce business logic.  For example if you enter a new record via the gui, it populates several tables, enforcing the business logic to insure that a "complete" record is created.  
Create a new company/contact record populates the company, person, address, phone, etc. tables.

When you use the COM object you have to populate each table separately.  Referential integrity checking is up to the programmer.  Hence, to see exactly what is happening, one can take advantage of a sql trace.

Anyway that is their application for better or for worse...FYI it is Sage Software...might as well be microsoft...can't show them the dooe ;)

Thanks,  Kevin.
LVL 29

Expert Comment

Comment Utility
We are on our 3rd Sage 'consultant' at the moment.

Some kind of data dictionary would be REALLY nice here - for you to have to capture the entire application business logic by profiling their system is insane. Do their COM datatypes also match up with the validation on the UI? Unlikely. So how do you know whether or not you have broken the integrity of the system when you post 10 into a tinyint field that the UI only allows 0-9?

Does the database enforce referenctial integrity at all? I.E. enetring a person with an invalid company will error out?

What version of Sage? Which software package? CRM, Accounting, etc...

Author Comment

Comment Utility
Sage CRM.

So far in my experience you can use their COM object to write data that the application can't interpret.

I have not messed around with their Web Services yet, so I'm not sure if it does any better job of enforcing things.

For your example, yes, I could create a person record and assign a company id to that person record even if that company id doesn't actually exist in the company table!

I happen to be a Sage 'consultant'...fortunately I am first and foremost a 'programmer'...and debugging other people's apps is my specialty so I feel right at home with this

Fun stuff.

Thanks, Kevin.

LVL 29

Expert Comment

Comment Utility
No way that I know of to automate this. And ideally you are going to want to work with a single connection to a system at a time (far easier to trace the logic if you know that there is only one connected user). Trying to split out the logic when there are hundreds (or even dozens) of concurrent connections will be painful in the extreme.

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now