Unique Session ID

In order to replace an Oracle DB with SQL-Server 2005 i need a unique session ID. The number Obtained by @@SPID is for reuse and does not meet my requirements. I'm looking for something like v$session.audsid in ORACLE.

Thanks

Raimund



Answer this question

Unique Session ID

  • John Askew

    hi raimund

    Auditing in sql server is done by running the sql profiler

    and then storing the trace to a table or a file.

    using the SQL Profiler

    you can use a lot of counters such as

    username, clientprocessid, spid, cpu,

    object names counters and many more

    Profiler can be run on a separate box

    I hope it can contribute to your solutions

    joey



  • abbarron

    The main purpose of this Session-Id is to Check wether the Connection is alive or not. Further there sould be the possibility to log the Session in an kind of audit trail even if the connection itself isn't alive anymore.

    Thanks

    Raimund


  • Waiman Li

    I dont know how oracle works.

    but if you want something unique you can use this

    DECLARE @myid uniqueidentifier
    SET @myid = NEWID()
    PRINT 'Value of @myid is: '+ CONVERT(varchar(255), @myid)

    these are called GUIDS - globally unique identifier




  • Shivakumara V

    You can use sys.dm_exec_connections.connection_id. But there is not that much value in persisting this information since it is a transient one. This is the closest to the Oracle audsid. You could alternatively log the sys.dm_exec_sessions.security_id which is the security identifier for the login along with the connection information. You can also take a look at the Audit:Login SQL Trace event details.

  • Whatonly

    i think you can also use

    sp_who

    Provides information about current MicrosoftR SQL Server users and processes. The information returned can be filtered to return only those processes that are not idle



  • Unique Session ID