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