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. Triggers in SQL

Triggers in SQL

Scheduled Pinned Locked Moved Database
databasehelpannouncement
3 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.
  • H Offline
    H Offline
    HowRU
    wrote on last edited by
    #1

    Hi, Please help me... I ve 2 tables like one is 'emp' & other is copy of 'empc' Wht i want...whenever i update the emp table the old contents should be moved to the empc table & the new should be overwritten in the emp table... & i want all this should be done through a trigger...may be on update... but...this will overwrite the contains of emp...so wht should i do.... Thanks

    H V 2 Replies Last reply
    0
    • H HowRU

      Hi, Please help me... I ve 2 tables like one is 'emp' & other is copy of 'empc' Wht i want...whenever i update the emp table the old contents should be moved to the empc table & the new should be overwritten in the emp table... & i want all this should be done through a trigger...may be on update... but...this will overwrite the contains of emp...so wht should i do.... Thanks

      H Offline
      H Offline
      Hesham Amin
      wrote on last edited by
      #2

      hi you need something like this :

      create trigger empCopyTrig on emp
      for Update
      as
      insert into empc Select * from deleted
      Go
      

      try it..Waiting for feedback :)

      1 Reply Last reply
      0
      • H HowRU

        Hi, Please help me... I ve 2 tables like one is 'emp' & other is copy of 'empc' Wht i want...whenever i update the emp table the old contents should be moved to the empc table & the new should be overwritten in the emp table... & i want all this should be done through a trigger...may be on update... but...this will overwrite the contains of emp...so wht should i do.... Thanks

        V Offline
        V Offline
        VenkatFor NET
        wrote on last edited by
        #3

        When using triggers to update a table, the rows which will be affected by the update statement will be available in 'deleted' table and records with updated changes will be available in 'inserted' table. These two tables are available only during trigger execution and not outside the scope of a trigger. BK Bhaskara

        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