Sometimes back, my friend told me that they had an application where users update their timesheets. He suspected that some users who had access to the database directly update some entries. He wanted to know whether some users update entries using a query analyser and not using the application. You can use a profiler for this.
Another method is to use app_name() function. App_name() function is used to return the name of the application from which data come. Consider the following example
declare @t table(
userid int,
timein datetime,
timeout datetime,
source varchar(200)
default app_name()
)
insert into @t(userid,timein,timeout)
select 1001,'20100710 08:30:20','20100710 18:45:00'
select * from @t
The result is
userid timein timeout source
------ ------------------- ------------------- ------------------------
1001 2010-07-10 08:30:20 2010-07-10 18:45:00 Microsoft SQL Server
Management Studio - Query
As you see the source specifies that data are inserted from Query Analyser. If you have any front end application like VB6, and add data to the table,
the source would specify it as "Visual Basic". So app_name() is a quick way of knowing where data come from.