Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. trace the computer name

trace the computer name

Scheduled Pinned Locked Moved Database
databasequestionsql-serversysadmindebugging
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Goodway
    wrote on last edited by
    #1

    hi everyone, In my company, 4 users are accessing the sql server with a username and a password, they are developers, they have rights to create tables, fields, insert rows, deleting rows,... how can I trace which computer make an insert or delete. for example if a user make an insert into a table from SQL Server enterprise manager by writing an insert query, how can i know which computer make this action? is that possible? thanks.

    M 1 Reply Last reply
    0
    • G Goodway

      hi everyone, In my company, 4 users are accessing the sql server with a username and a password, they are developers, they have rights to create tables, fields, insert rows, deleting rows,... how can I trace which computer make an insert or delete. for example if a user make an insert into a table from SQL Server enterprise manager by writing an insert query, how can i know which computer make this action? is that possible? thanks.

      M Offline
      M Offline
      miah alom
      wrote on last edited by
      #2

      I think you are looking for HOST_NAME() http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ha-hz_05r9.asp[^]

      G 1 Reply Last reply
      0
      • M miah alom

        I think you are looking for HOST_NAME() http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ha-hz_05r9.asp[^]

        G Offline
        G Offline
        Goodway
        wrote on last edited by
        #3

        Thanks, but this give me the computer name when a row is added, when a row is updated or deleted nothing is logged. I can't know who update a specific record. any other idea. thanks again.

        M 1 Reply Last reply
        0
        • G Goodway

          Thanks, but this give me the computer name when a row is added, when a row is updated or deleted nothing is logged. I can't know who update a specific record. any other idea. thanks again.

          M Offline
          M Offline
          miah alom
          wrote on last edited by
          #4

          I have solved this problem in a different way. When the user logs in to the application, I insert the kerberos user id and the hostname in a Activity table. But there is a limitation. One user cannot start two instances of the application from the same host. So when there is a update or delete or insert, I pick up the value from this table. Everytime the user logs in, I clear the Activity for that user in a host machine. CREATE PROCEDURE ValidateUser ( @userid varchar(10) ) AS DECLARE @cnt int BEGIN DELETE FROM Activity WHERE Host = host_name() INSERT INTO Activity VALUES(host_name(),@userid) SELECT @cnt = count(*) FROM Users WHERE ID = @userid IF @cnt = 1 SELECT 1 ELSE SELECT 0 END In the trigger I do something like IF @@rowcount = 0 RETURN SELECT @user = CurrentUser FROM Activity WHERE Host = host_name() IF UPDATE(Column1) INSERT INTO AuditTrail SELECT @user,getdate(),'Table1','Column1' --blah blah FROM deleted,inserted WHERE ------------------- Does this help.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups