Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger to return SqlCommand

Status
Not open for further replies.

mjhessler

Programmer
Mar 17, 2004
18
US
What can be done to have a trigger return the SqlCommand or sql statements responsible for the change?

I am using app_name() and host_name() and am hoping to learn of a similar function that will give the T-SQL code/statements/commands.

I have checked all of the stored procedures, but they aren't the source of the problem. The application code must have a glitch. I am assuming that SQL Server 2000 has the T-SQL being run stored while it's running. I want to learn how to access it.

Where does SQL store the “Last TSQL command batch” or the “Process Details” or the command that is displayed by EM, Management, Current Activity, Process Information, Command?
 
How do I select the EventInfo value from DBCC INPUTBUFFER (SPID) into @EventInfo?

DECLARE @spid int
DECLARE @EventInfo nvarchar(255)
SELECT
[USER_NAME()] = USER_NAME()
,[HOST_NAME ()] = HOST_NAME()
,[host_id()] = host_id()
,[SYSTEM_USER] = SYSTEM_USER
,[app_name()] = app_name()
,[@@spid] = @@spid
SET @spid =@@spid
dbcc inputbuffer (@spid)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top