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. Before Update Triggers and changing inserted recordset

Before Update Triggers and changing inserted recordset

Scheduled Pinned Locked Moved Database
questiondatabasetutorialannouncement
2 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.
  • L Offline
    L Offline
    Leo Smith
    wrote on last edited by
    #1

    I would like to know how I can set a new value into the triggers inserted recordset. Example: All dates on or before 1/1/1900 are to be set to null. Then a date in the fourth column comes in as 1/1/1900 in the inserted column. I can find out that the value needs to be set, but how can I change it to null before it is actually set in the database? Thanks,

    Leo T. Smith Program/Analyst Supervisor

    P 1 Reply Last reply
    0
    • L Leo Smith

      I would like to know how I can set a new value into the triggers inserted recordset. Example: All dates on or before 1/1/1900 are to be set to null. Then a date in the fourth column comes in as 1/1/1900 in the inserted column. I can find out that the value needs to be set, but how can I change it to null before it is actually set in the database? Thanks,

      Leo T. Smith Program/Analyst Supervisor

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      You could use an INSTEAD OF UPDATE trigger that fires when an UPDATE statement is executed against your table. The inserted table would contain details of the changes which were going to be made. You can then examine these values and execute a different UPDATE statement which either updates the fields as they were originally going to be updated, or sets fields to NULL where the value <= 1/1/1900.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      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