This is a mirror of official site: http://jasper-net.blogspot.com/

SQL Server App_name() function - find out which application has modified your data

| Monday, August 2, 2010
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

Read more: Beyond Relational

Posted via email from .NET Info

0 comments: