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. Create trigger that executes on date

Create trigger that executes on date

Scheduled Pinned Locked Moved Database
csharpasp-netdatabasetutorialquestion
7 Posts 3 Posters 1 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.
  • D Offline
    D Offline
    damokk
    wrote on last edited by
    #1

    Hi. I am creating an application that uses sqlserver and asp.net c#. I need to create a trigger that inserts data into a table 30 days before an expiry date field in another table. I have created the trigger but dont know how to implement the dates? Any suggestions would be appreciated.

    C M 2 Replies Last reply
    0
    • D damokk

      Hi. I am creating an application that uses sqlserver and asp.net c#. I need to create a trigger that inserts data into a table 30 days before an expiry date field in another table. I have created the trigger but dont know how to implement the dates? Any suggestions would be appreciated.

      C Offline
      C Offline
      Corporal Agarn
      wrote on last edited by
      #2

      Does the date go in when the "expiry date" column is populate or do you want it to go in 30 days before the date?

      D 1 Reply Last reply
      0
      • D damokk

        Hi. I am creating an application that uses sqlserver and asp.net c#. I need to create a trigger that inserts data into a table 30 days before an expiry date field in another table. I have created the trigger but dont know how to implement the dates? Any suggestions would be appreciated.

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        What you are describing is not a trigger spit but a JOB, the job would call a proc that checks for expiry dates 30 days away and insert the appropriate record. You would schedule the JOB to run daily.

        Never underestimate the power of human stupidity RAH

        D 1 Reply Last reply
        0
        • M Mycroft Holmes

          What you are describing is not a trigger spit but a JOB, the job would call a proc that checks for expiry dates 30 days away and insert the appropriate record. You would schedule the JOB to run daily.

          Never underestimate the power of human stupidity RAH

          D Offline
          D Offline
          damokk
          wrote on last edited by
          #4

          thanks for the reply. I had a feeling a trigger would be difficult or impossible to implement in this way.. Not sure how to create this job tho. Any pointers would be appreciated?

          1 Reply Last reply
          0
          • C Corporal Agarn

            Does the date go in when the "expiry date" column is populate or do you want it to go in 30 days before the date?

            D Offline
            D Offline
            damokk
            wrote on last edited by
            #5

            I already have a table with an appointment date entered. I need to update another table 30 days before before this appointment date. Thanks

            M 1 Reply Last reply
            0
            • D damokk

              I already have a table with an appointment date entered. I need to update another table 30 days before before this appointment date. Thanks

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              Create a stored procedure that does the following Get the expiring records insert the relevant data into the target table. In SSMS create a Job that calls the stored proc schedule the job to run every day

              Never underestimate the power of human stupidity RAH

              D 1 Reply Last reply
              0
              • M Mycroft Holmes

                Create a stored procedure that does the following Get the expiring records insert the relevant data into the target table. In SSMS create a Job that calls the stored proc schedule the job to run every day

                Never underestimate the power of human stupidity RAH

                D Offline
                D Offline
                damokk
                wrote on last edited by
                #7

                thanks I'll give it a try!

                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