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. Insert before update -the first data- in a historical table

Insert before update -the first data- in a historical table

Scheduled Pinned Locked Moved Database
announcement
8 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.
  • F Offline
    F Offline
    foryou
    wrote on last edited by
    #1

    Hi! I work with Sqlserver2005 and I have a table which I update, I need to insert the data before update in a table History. is a way to do that. Thank you in advance.

    B 1 Reply Last reply
    0
    • F foryou

      Hi! I work with Sqlserver2005 and I have a table which I update, I need to insert the data before update in a table History. is a way to do that. Thank you in advance.

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      Insert into TableName Values('val1','val2'.....) Update TableName set Col1='val1', Col2='val2'..... where ColName=ValCondition For better answer,post more detailed questin.


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

      F 1 Reply Last reply
      0
      • B Blue_Boy

        Insert into TableName Values('val1','val2'.....) Update TableName set Col1='val1', Col2='val2'..... where ColName=ValCondition For better answer,post more detailed questin.


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

        F Offline
        F Offline
        foryou
        wrote on last edited by
        #3

        Thanks Blue_Boy; sorry my english is bad ! I have two tables Table1 and historical_table1. With the same properties and the data are displayed in a gridview in editable mode . when the user modify a line of table1 I want that the first data (before update) will be inserted in historical_table1 automatically. Thanks .

        B 1 Reply Last reply
        0
        • F foryou

          Thanks Blue_Boy; sorry my english is bad ! I have two tables Table1 and historical_table1. With the same properties and the data are displayed in a gridview in editable mode . when the user modify a line of table1 I want that the first data (before update) will be inserted in historical_table1 automatically. Thanks .

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          Use triggers[^]. While updating data in table Table1 (I sugggest you to rename this table 'Table1' and give it any meaningful name) execute trigger which do insert in historical_table1.


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

          F 1 Reply Last reply
          0
          • B Blue_Boy

            Use triggers[^]. While updating data in table Table1 (I sugggest you to rename this table 'Table1' and give it any meaningful name) execute trigger which do insert in historical_table1.


            I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

            F Offline
            F Offline
            foryou
            wrote on last edited by
            #5

            Thanks a lot Blue_Boy; I must document on triggers because its the first time I heard trigger in database, thank you very much. if you know a course for beginners on the triggers thank you pass me the link. :)

            B 1 Reply Last reply
            0
            • F foryou

              Thanks a lot Blue_Boy; I must document on triggers because its the first time I heard trigger in database, thank you very much. if you know a course for beginners on the triggers thank you pass me the link. :)

              B Offline
              B Offline
              Blue_Boy
              wrote on last edited by
              #6

              No problem,I am glad to help you. Check this link.[^]


              I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

              F 1 Reply Last reply
              0
              • B Blue_Boy

                No problem,I am glad to help you. Check this link.[^]


                I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

                F Offline
                F Offline
                foryou
                wrote on last edited by
                #7

                Merci beaucoup Blue_Boy.

                B 1 Reply Last reply
                0
                • F foryou

                  Merci beaucoup Blue_Boy.

                  B Offline
                  B Offline
                  Blue_Boy
                  wrote on last edited by
                  #8

                  You are welcome. :)


                  I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

                  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