Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    44

    Unanswered: See the SQL for a spid

    All,

    Is there any way to see the SQL for any given spid in SQL server?

    I can see "properties" under enterprise mgr - which shows you a snippet of the SQL - or "sp_execute" depending on what you use to get to the DBMS.

    Is there a way to take a deeper look?

    Thanks,

    Isaac

  2. #2
    Join Date
    Jun 2003
    Posts
    269
    Code:
    use master
    go
    select sql_handle from sysprocesses where spid= @spid
    -- copy that result to bolded area,
    select text from ::fn_get_sql(sql_handle)
    --eg: select * from ::fn_get_sql(0x01000100E308101398005C2A0000000000000000)
    I love cursor,though I never use it.Cos' I dont want to misuse it.
    ----------------------------------------------

    ----cheers
    ----http://mallier.blogspot.com

  3. #3
    Join Date
    Dec 2002
    Posts
    1,245
    Quote Originally Posted by ieruiz
    All,

    Is there any way to see the SQL for any given spid in SQL server?

    I can see "properties" under enterprise mgr - which shows you a snippet of the SQL - or "sp_execute" depending on what you use to get to the DBMS.

    Is there a way to take a deeper look?

    Thanks,

    Isaac
    Try this link: http://vyaskn.tripod.com/fn_get_sql.htm There's a lot more information there than what you really nead, but it gives a good overview. You can also look up fn_get_sql() in SQL BOL.

    Warning: it only works with SQL 2000 SP3 or higher.

    Regards,

    hmscott
    Have you hugged your backup today?

Posting Permissions

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