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. Web Development
  3. ASP.NET
  4. insert trigger

insert trigger

Scheduled Pinned Locked Moved ASP.NET
databasequestion
4 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.
  • P Offline
    P Offline
    playout
    wrote on last edited by
    #1

    Hi, I have code that fires a stored procedure, to insert a new location. I now need to add another insert, that inserts a destination into another table, using a trigger. I pass the following variable to my location table : @LocationCode I want to create a trigger, that everytime an INSERT is fired on the Location table, it should add a row to my Destination table. Here is what I have to create the trigger: CREATE TRIGGER DestInsert ON [Location] FOR INSERT AS INSERT INTO Destination (LocationCode, Destination, AreaCode, DeletedFlag) VALUES (@LocationCode, 'New', '123C', 0) Will this create a trigger for me, that adds the same @LocationCode variable I added for the stored Procedure to the trigger?

    D 1 Reply Last reply
    0
    • P playout

      Hi, I have code that fires a stored procedure, to insert a new location. I now need to add another insert, that inserts a destination into another table, using a trigger. I pass the following variable to my location table : @LocationCode I want to create a trigger, that everytime an INSERT is fired on the Location table, it should add a row to my Destination table. Here is what I have to create the trigger: CREATE TRIGGER DestInsert ON [Location] FOR INSERT AS INSERT INTO Destination (LocationCode, Destination, AreaCode, DeletedFlag) VALUES (@LocationCode, 'New', '123C', 0) Will this create a trigger for me, that adds the same @LocationCode variable I added for the stored Procedure to the trigger?

      D Offline
      D Offline
      DineshSharma
      wrote on last edited by
      #2

      use.. Inserted.Locationcode it will fetch the location code from inserted location enjoy :)

      Dinesh Sharma

      P 1 Reply Last reply
      0
      • D DineshSharma

        use.. Inserted.Locationcode it will fetch the location code from inserted location enjoy :)

        Dinesh Sharma

        P Offline
        P Offline
        playout
        wrote on last edited by
        #3

        DineshSharma wrote:

        Inserted.Locationcode

        Thanks, just one more thing. Is Inserted a DB function, or does it gets the last LocationCode inserted?

        P 1 Reply Last reply
        0
        • P playout

          DineshSharma wrote:

          Inserted.Locationcode

          Thanks, just one more thing. Is Inserted a DB function, or does it gets the last LocationCode inserted?

          P Offline
          P Offline
          Paddy Boyd
          wrote on last edited by
          #4

          It's a table that contains all the rows that were inserted when the trigger was fired.

          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