Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    25

    Unhappy Unanswered: How to get the last Query executed?

    Hello, i have a trigger and i want to know the query that raised it, or want to retrieve the last executed query by the server. I think it's a hard question but i know that someone can help me... Thanks

  2. #2
    Join Date
    Jul 2002
    Posts
    58

    Re: How to get the last Query executed?

    Originally posted by parmaia
    Hello, i have a trigger and i want to know the query that raised it, or want to retrieve the last executed query by the server. I think it's a hard question but i know that someone can help me... Thanks
    Fire up SQL Profiler and run a trace with the filters configured to limit it to the table in question (object).

  3. #3
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Code:
    if object_id('dbo.test') is not null
       drop table dbo.test
    go
    create table dbo.test (f1 int null)
    go
    create trigger dbo.trgIUD_test on dbo.test for insert, update, delete as
       dbcc inputbuffer (@@spid)
    go
    insert dbo.test values (1);
    go
    drop table dbo.test
    go

  4. #4
    Join Date
    Feb 2004
    Posts
    25

    Thumbs up Re: How to get the last Query executed?

    Originally posted by Steve Duncan
    Fire up SQL Profiler and run a trace with the filters configured to limit it to the table in question (object).
    Hey, i didn't know that exists, thank you for your help!, has very very use full!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •