Results 1 to 5 of 5
  1. #1
    Join Date
    May 2006
    Posts
    38

    Lightbulb Unanswered: Last Query Statement fired into the MSSQL Engine

    Hi,

    How can you get the Query Statement of the last executed SQL command.

    I am not quite sure but I do remember coming across such a command ( maybe an undocumented one).

    Thanks for your help and pointers.

    My Best wishes for the new year to all the folks in the forum. Wishing you greater days ahead.

    Warm Regards,
    Ranjit S Hans.

    ---------------------------------------------------------------------
    Everywhere is a walking distance if you have the time - Steven Wright

  2. #2
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    dbcc inputbuffer(@spid)

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    You can also use fn_get_sql, but it is a little more awkward.

  4. #4
    Join Date
    May 2006
    Posts
    38
    Hi Matt/ Jezemine,

    Thanks so much for the help .. You have been wonderful all along.

    I am looking forward to try out using fn_get_sql sometime soon.

    Thanks once again !!

    Warm Regards,
    Ranjit S Hans
    -----------------------------------------------------------------------
    Everywhere is a walking distance if you have the time - Steven Wright

  5. #5
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    fn_get_sql has a number of benefits over dbcc inputbuffer actually. dbcc cuts off the query returned at 255 chars as I recall. Usually thats enough, unless you have apps out there making ad-hoc sql calls doing a 10-way join.

Posting Permissions

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