Skip to main content
Gear_Head
Known Participant
October 9, 2009
Question

Moving data from one table to another

  • October 9, 2009
  • 1 reply
  • 1643 views

Hi,

I havent done CF in a log time and i have a question,

My client has an admin site for his inventory in a db (MS SQL) one of the table (inventory) has 180 fields (which are options for the items) with around 100 records that are being added/deleted per week, he now whants to keep the deleted data has reference to what happened to them.

What i want to do is move all the data berofe deleting the record of Inventory to inventory_deleted without having to specify all the 180 fields name to be moved 🙂   yep lazy

I already copied the table without the data all i need is some sort of query to move invetory_deleted before I delete it from inventory

I'v tryed adding a active/deleted field to the table, but this is a huge site and it causes to many problems everywhere else when showing data, stats ...etc

here is the delete code 🙂

<cfquery datasource="#clientds#">
      DELETE FROM inventory
      WHERE inv_number=#form.inv_num#
    </cfquery>

and this is what i tested so far

<cfquery datasource="#clientds">
insert into inventory_deleted (*)
select *
from inventory

WHERE inv_number=#form.inv_num#
</cfquery>

Help would be really apreciated

This topic has been closed for replies.

1 reply

Inspiring
October 9, 2009

Add a char(1) field named active or something like that.  Make the default value Y.  Update it to N instead of deleting the record.

Gear_Head
Gear_HeadAuthor
Known Participant
October 9, 2009

Like i said in the post i tryed that :

I'v tryed adding a active/deleted field to the table, but this is a huge

site and it causes to many problems everywhere else when showing data, stats

...etc

Will turn out to be more work then typing all the fields