简体   繁体   中英

Determining what stored procedures are run from an application

We have a third party application where data is entered manually one record at a time where the user reads data from an Excel spreadsheet.

I have been asked to enable a way to upload data to the SQL Server database from the Excel spreadsheets. This would save a ton of time and prevent mistakes during manual data entry. I've done this type of work before but with in-house programs. I need to find what processes are run when the Save button is clicked. Is there a way to determine this or something similar (like exactly what tables\\triggers are involved besides the ones I already know of)?

To discover the database activity the best way is to set up a test copy of the application and a test database where there is only 1 person working. Then start a SQL Profiler trace and record what happens in the database after clicking the Save button.

That said, do not be at all surprised if you do not get a complete picture of what you need. This will not reveal anything that happens to the data within the client application before being sent to the database. Reverse engineering an application can be just as error prone as the manual effort involved with normal data entry. On top of it, there is no guarantee that that process will remain the same for updated versions of the application.

If you don't have access to the original source code, then you can enter something like this in SSMS to see which queries have been run recently by a specific machine (substitute in your host name in line 2 and then walk through the process to get a pretty good idea of what is going on). This was adapted from an existing answer on SO to work for a single host, but I have no idea how to track it down to give proper credit...

declare @host varchar(50)
set @host='MyComputerName'


SELECT TEXT
FROM sys.dm_exec_connections
CROSS APPLY sys.dm_exec_sql_text(most_recent_sql_handle)
WHERE session_id in
(SELECT des.session_id FROM sys.dm_exec_sessions des WHERE des.is_user_process = 1 AND host_name = @host);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM