Note that there are some explanatory texts on larger screens.

plurals
  1. POMove Records from "Active Tables" to "Archive Tables" in SQL Server 2012
    primarykey
    data
    text
    <p>This one is tricky to me in the since of SQL. I have 4 Tables. I'm having more a logic issue than anything else I think. I have a table called Vehicle. Within my application, any record changed in this Vehicle table gets inserted into a VLog table. The Primary key for Vehicle is VehicleID and it is related to VehicleID in VLog. In SQL, I'm not positive how to archive both of these tables. I have two archive tables. VehicleArchive and VLogArchive. Within my application, I'm able to "Archive" certain records based on a certain parameter. This was easy as I was using a gridview and could verify the VehicleID and Insert any record with that VehicleID into VLogArchive and VehicleArchive. However, I'm going to be dealing with live records and was wondering if there is a solution in SQL. There are multiple records for each VehicleID in VLog as VLog keeps track of all the changes made in Vehicle. Within my application itself, On "Update" button click, I was able to Insert the records with from VLog into VLogArchive by comparing it to the VehicleID within the gridview and then removing said records from VLog and the Location was changed to "File Room." It then goes on to insert the records from Vehicle into VehicleArchive also by comparing it to the VehicleID within the gridview again as long as the Location is "File Room." It seems backwards but I had to do it this way because if I tried to remove a record from Vehicle before removing the related records from VLog, it wouldn't delete as it is related. I do not know how to do this approach in SQL and was wondering if someone knew how to go about moving all the records at the same time if the Location is in "File Room."</p> <p>I have found <a href="https://stackoverflow.com/questions/1612267/move-sql-data-from-one-table-to-another/1612292#1612292">this</a> and <a href="https://stackoverflow.com/questions/16234782/move-records-which-are-older-than-3-years-from-one-database-production-db-to-a">this</a> but I'm not positive these are the approaches that I need. Thanks for the help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload