HOW TO KNOW PROCESS ID

  • I NEED TO KNOW USING T-SQL  THE PROCESS ID FROM THE CURRENT SESSION CONNECTED TO SQL. EXIST SOMETHING LIKE @@SERVERNAME, SELECT USER.

    I HAVE TO USE THI COMMAND IN A .NET APPLICATION TO RETRIEVE THIS INFORMATION.

    THANKS FOR ANY SUGGESTION.

  • Did you try SELECT * FROM master..sysprocesses?

  • sp_who2 ????? It's hard to tell what you are really looking for. Can you be more specific?

    -SQLBill

  • I have found sp_who2 to generate better results, but it does not take parameters well...

    I wasn't born stupid - I had to study.

  • SELECT @@SPID

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • SELECT

    spid, rtrim(status) as status, RTRIM(loginame) AS loginame, rtrim(hostname) as machine,

    rtrim(CONVERT(char(5), blocked)) AS blk, DB_NAME(dbid) AS dbname, rtrim(program_name) as programa,cmd,

    physical_io

    , memusage,open_tran,net_library,login_time as TiempoInicio,last_batch as UltimoBach

    FROM master.dbo.sysprocesses a where ecid = 0 and RTRIM(loginame) = 'XXXX'

     

    This query return the same result that sp_who2 and 'XXXX' is to filter result for user connect to database.

    Column  spid is process number

  • The configuration function @@SPID (SELECT @@SPID) is probably the easiest and least time consuming to implement.



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

  • Like I said....

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=9&messageid=350069#bm350229

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply