Trigger table read?

  • Is there a trigger that is activated when a table/row is read?

  • No. Insert, update and delete only.

    What are you trying to do?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • jayg359 - Saturday, November 11, 2017 9:25 PM

    Is there a trigger that is activated when a table/row is read?

    Are you trying to audit the select statements?
    😎

  • Thanks for your replies.
    I was  looking at running a stored procedure each time certain data was being read.

  • jayg359 - Monday, November 13, 2017 7:06 AM

    Thanks for your replies.
    I was  looking at running a stored procedure each time certain data was being read.

    Maybe you could have the report or application call the stored procedure to read the data instead of querying the table directly?

  • Chris Harshman - Monday, November 13, 2017 10:21 AM

    jayg359 - Monday, November 13, 2017 7:06 AM

    Thanks for your replies.
    I was  looking at running a stored procedure each time certain data was being read.

    Maybe you could have the report or application call the stored procedure to read the data instead of querying the table directly?

    Yes, this is an option. But I was looking to try to have it run on the server entirely.

  • jayg359 - Monday, November 13, 2017 8:32 PM

    Chris Harshman - Monday, November 13, 2017 10:21 AM

    jayg359 - Monday, November 13, 2017 7:06 AM

    Thanks for your replies.
    I was  looking at running a stored procedure each time certain data was being read.

    Maybe you could have the report or application call the stored procedure to read the data instead of querying the table directly?

    Yes, this is an option. But I was looking to try to have it run on the server entirely.

    What will the stored procedure do?  There is a trick or two that can help in the area of when a table is read but we have to know what it is that you're trying to accomplish with the stored procedure.

    --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)

  • Jeff Moden - Monday, November 13, 2017 10:53 PM

    jayg359 - Monday, November 13, 2017 8:32 PM

    Chris Harshman - Monday, November 13, 2017 10:21 AM

    jayg359 - Monday, November 13, 2017 7:06 AM

    Thanks for your replies.
    I was  looking at running a stored procedure each time certain data was being read.

    Maybe you could have the report or application call the stored procedure to read the data instead of querying the table directly?

    Yes, this is an option. But I was looking to try to have it run on the server entirely.

    What will the stored procedure do?  There is a trick or two that can help in the area of when a table is read but we have to know what it is that you're trying to accomplish with the stored procedure.

    I would be searching for new data and make some update based on it.

  • jayg359 - Tuesday, November 14, 2017 6:28 AM

    Jeff Moden - Monday, November 13, 2017 10:53 PM

    jayg359 - Monday, November 13, 2017 8:32 PM

    Chris Harshman - Monday, November 13, 2017 10:21 AM

    jayg359 - Monday, November 13, 2017 7:06 AM

    Thanks for your replies.
    I was  looking at running a stored procedure each time certain data was being read.

    Maybe you could have the report or application call the stored procedure to read the data instead of querying the table directly?

    Yes, this is an option. But I was looking to try to have it run on the server entirely.

    What will the stored procedure do?  There is a trick or two that can help in the area of when a table is read but we have to know what it is that you're trying to accomplish with the stored procedure.

    I would be searching for new data and make some update based on it.

    I don't understand how that has anything to do with your original thought of running a proc when a table was read.  What are you trying to do?  Audit access/usage of the table?  You need to be specific because it does make a difference in how to accomplish such a thing.

    --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)

  • I'd be interested in Auditing read/access/usage of a table 🙂

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Jeff Moden - Tuesday, November 14, 2017 7:01 AM

    jayg359 - Tuesday, November 14, 2017 6:28 AM

    Jeff Moden - Monday, November 13, 2017 10:53 PM

    jayg359 - Monday, November 13, 2017 8:32 PM

    Chris Harshman - Monday, November 13, 2017 10:21 AM

    jayg359 - Monday, November 13, 2017 7:06 AM

    Thanks for your replies.
    I was  looking at running a stored procedure each time certain data was being read.

    Maybe you could have the report or application call the stored procedure to read the data instead of querying the table directly?

    Yes, this is an option. But I was looking to try to have it run on the server entirely.

    What will the stored procedure do?  There is a trick or two that can help in the area of when a table is read but we have to know what it is that you're trying to accomplish with the stored procedure.

    I would be searching for new data and make some update based on it.

    I don't understand how that has anything to do with your original thought of running a proc when a table was read.  What are you trying to do?  Audit access/usage of the table?  You need to be specific because it does make a difference in how to accomplish such a thing.

    each time credentials of a user is read, i know that he is accessing the system, I want to record this. I don't have access to the front end program so I want to do this on the back-end in the db.

  • jayg359 - Monday, November 20, 2017 10:40 AM

    Jeff Moden - Tuesday, November 14, 2017 7:01 AM

    jayg359 - Tuesday, November 14, 2017 6:28 AM

    Jeff Moden - Monday, November 13, 2017 10:53 PM

    jayg359 - Monday, November 13, 2017 8:32 PM

    Chris Harshman - Monday, November 13, 2017 10:21 AM

    jayg359 - Monday, November 13, 2017 7:06 AM

    Thanks for your replies.
    I was  looking at running a stored procedure each time certain data was being read.

    Maybe you could have the report or application call the stored procedure to read the data instead of querying the table directly?

    Yes, this is an option. But I was looking to try to have it run on the server entirely.

    What will the stored procedure do?  There is a trick or two that can help in the area of when a table is read but we have to know what it is that you're trying to accomplish with the stored procedure.

    I would be searching for new data and make some update based on it.

    I don't understand how that has anything to do with your original thought of running a proc when a table was read.  What are you trying to do?  Audit access/usage of the table?  You need to be specific because it does make a difference in how to accomplish such a thing.

    each time credentials of a user is read, i know that he is accessing the system, I want to record this. I don't have access to the front end program so I want to do this on the back-end in the db.

    Ah... OK.  Now I get it.  Would a login trigger do it for you?  Or are you really just interested if the user hits a certain table?

    --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 12 posts - 1 through 11 (of 11 total)

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