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. LastModifiedDate

LastModifiedDate

Scheduled Pinned Locked Moved Database
databasequestiondiscussionannouncement
8 Posts 3 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
    geekfromindia
    wrote on last edited by
    #1

    Hi guys, We have a column "LastModifiedDate" columns in almost all our tables. We are currently using procedures to update lastupdateddate column. but every now and then developers forget to add this to their query. Is their a way to make this automatic...should we use triggers for this??... But again I m not sure if we should add triggers to all tables... what's the best practice for this? Any suggestions??

    Keep DotNetting!! GeekFromIndia

    W N 2 Replies Last reply
    0
    • G geekfromindia

      Hi guys, We have a column "LastModifiedDate" columns in almost all our tables. We are currently using procedures to update lastupdateddate column. but every now and then developers forget to add this to their query. Is their a way to make this automatic...should we use triggers for this??... But again I m not sure if we should add triggers to all tables... what's the best practice for this? Any suggestions??

      Keep DotNetting!! GeekFromIndia

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Use triggers. Much better solution than to use separate procedure.

      G 1 Reply Last reply
      0
      • W Wendelius

        Use triggers. Much better solution than to use separate procedure.

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

        we are not using separate procs but every procs that updates any table...it updates this column also...

        Keep DotNetting!! GeekFromIndia

        W 1 Reply Last reply
        0
        • G geekfromindia

          we are not using separate procs but every procs that updates any table...it updates this column also...

          Keep DotNetting!! GeekFromIndia

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #4

          So is every update and insert done via stored procedure and the developers are writing the procedures? If that is true I would still go to triggers. In this way the database takes care of critical information (I understood that the date must be modified every time) and the developers don't have to remember to add this column to every DML operation. Also DML executed directly against the table is setting the date correctly if triggers are used. Just wondering how you use the LastModifiedDate. If it simply shows the date when the record is last modified, it's ok. However if you use it for optimistic locking, the resolution isn't adequate. Mika

          G 1 Reply Last reply
          0
          • W Wendelius

            So is every update and insert done via stored procedure and the developers are writing the procedures? If that is true I would still go to triggers. In this way the database takes care of critical information (I understood that the date must be modified every time) and the developers don't have to remember to add this column to every DML operation. Also DML executed directly against the table is setting the date correctly if triggers are used. Just wondering how you use the LastModifiedDate. If it simply shows the date when the record is last modified, it's ok. However if you use it for optimistic locking, the resolution isn't adequate. Mika

            G Offline
            G Offline
            geekfromindia
            wrote on last edited by
            #5

            Thanks Mika, We are using it to update date for any change in the table...i guess i will be using triggers only.. thanks again for help

            Keep DotNetting!! GeekFromIndia

            W 1 Reply Last reply
            0
            • G geekfromindia

              Thanks Mika, We are using it to update date for any change in the table...i guess i will be using triggers only.. thanks again for help

              Keep DotNetting!! GeekFromIndia

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #6

              You're welcome :)

              1 Reply Last reply
              0
              • G geekfromindia

                Hi guys, We have a column "LastModifiedDate" columns in almost all our tables. We are currently using procedures to update lastupdateddate column. but every now and then developers forget to add this to their query. Is their a way to make this automatic...should we use triggers for this??... But again I m not sure if we should add triggers to all tables... what's the best practice for this? Any suggestions??

                Keep DotNetting!! GeekFromIndia

                N Offline
                N Offline
                nelsonpaixao
                wrote on last edited by
                #7

                Hi, i don´t know if i can help you there but use sql getdatetime() function to get date automatically. You will get time when the procedure is triggered, don´t even need to ask nothing to the user. I had a application on which i manage the login/logout process automatically, the user doesn´t even know that it exists algorithm: create table log_table(id int,user varchar(50),login smalldatetime, logout smalldatetime) --in login procedure insert into log_table(235,john,getdatetime(), null) --in logout procedure insert into log_table(235,john,null,getdatetime()) Good Luck :-D

                nelsonpaixao@yahoo.com.br

                G 1 Reply Last reply
                0
                • N nelsonpaixao

                  Hi, i don´t know if i can help you there but use sql getdatetime() function to get date automatically. You will get time when the procedure is triggered, don´t even need to ask nothing to the user. I had a application on which i manage the login/logout process automatically, the user doesn´t even know that it exists algorithm: create table log_table(id int,user varchar(50),login smalldatetime, logout smalldatetime) --in login procedure insert into log_table(235,john,getdatetime(), null) --in logout procedure insert into log_table(235,john,null,getdatetime()) Good Luck :-D

                  nelsonpaixao@yahoo.com.br

                  G Offline
                  G Offline
                  geekfromindia
                  wrote on last edited by
                  #8

                  yeah...thats the way we are doing right now... but if your table is accessible at many places/procs in application it can be difficult to manage or make sure that every developer is adding this attribute. if anyone missed it..our business logic will fail...so i feel its better to add a trigger once and forget about it.. but i was wondering if there are any disadvantages of using triggers???

                  Keep DotNetting!! GeekFromIndia

                  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