Is the great god, and in A table, A of the data for several months, imonth is in the table, now want to take the F1 this field last month's data, if it is in August, want to get data into July F1 F2, how to write this statement? If it is written to the trigger, every month in the table to modify the trigger automatically at the time of how to write?
CodePudding user response:
You this inmonth fields in what is the format of the data, if this is 202007 format, try it with the following
UPDATE A The SET of F2=F1 WHERE imonth=the CONVERT (VARCHAR (6), DATEADD (MONTH, 1, GETDATE ()), 112)
Words you don't need to use the trigger, set up a regular job, specify date batch update once a month,
CodePudding user response:
This imonth in the background of the digital display is 1 2, the data type tinyint this cannot set the timer because could literally change into table, every change need to recalculate the field