--You can easily see the last statement sent from a client to an instance
--of Microsoft SQL Server by looking at DBCC inputbuffer, but I guess that
--it is the actual Access query that you want to know about.
--However, this might help to see what is going on in a database
CREATE PROCEDURE spMySpids
@Database SYSNAME --the name of the database
AS
--spMySpids 'NorthWind'
DECLARE @DynamicSQL VARCHAR(MAX)
SELECT @DynamicSQL='Declare @MySpids table
(
MySpid_ID int identity(1,1),
spid int,
EventType nvarchar(30),--Event type. This could be RPC
--Event or Language Event.
--The output will be No Event when no
--last event was detected.
Parameters int, --0 = Text 1- n = Parameters
EventInfo nvarchar(4000) --For an EventType of RPC,
--EventInfo contains only the procedure name.
--For an EventType of Language, only the first 4000 characters
--of the event are displayed.
)
'
SELECT @DynamicSQL=@DynamicSQL+'
insert into @MySpids (EventType, Parameters, EventInfo)
execute (''dbcc inputbuffer ('+CONVERT(VARCHAR(5),spid)+')'')
update @MySpids set spid='
+CONVERT(VARCHAR(5),spid)
+' where MySpid_ID=@@identity
'
FROM MASTER.dbo.sysprocesses WHERE dbid=DB_ID (@database)
SELECT @DynamicSQL=@DynamicSQL+'
Select * from @MySpids'
EXECUTE (@DynamicSQL)