Does any one know how to delete rows from one table and add them to
another table at the same time. All using a stored procedure or a trigger.
T.I.A :)
T.I.A :)
INSERT newTable
SELECT * FROM oldTable
TRUNCATE oldTable
If there is a WHERE clause to filter the data, you may try
something along the lines of
INSERT newTable
SELECT * FROM oldTable
WHERE <criteria>
DELETE FROM oldTable
WHERE <criteria>
If the COLUMNs are different, you have to specify the
COLUMN NAMES in the SELECT clause.
- Anith
procedure or a trigger.Quote:>-----Original Message-----
>Does any one know how to delete rows from one table and
add them to
>another table at the same time. All using a stored
Quote:>T.I.A :)
>.
Create trigger dbo.name for delete as (check syntax)
Insert tab_name_2 select a, b,c from deleted
deleted contains the data deleted from 1st table .
Hope it hhelps
You may create a trigger for delete. In the delete trigger, utilize the
"deleted" table to insert the records to another table. For more
information, please refer to the BOL.
Thanks,
Jun Chen
This posting is provided "AS IS" with no warranties, and confers no rights.
1. combining rows from a table in to one row
Hi,
I'm trying to combine several rows from a table in to one row.
For example here's the table as it stands:
CUST_NO, FEE_AMT
i'd like to make it
CUST_NO, FEE_AMT1, FEE_AMT2, FEE_AMT3 etc up to FEE_AMT8
Any ideas?
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
3. Combing multiple row data into one row in another table
4. postgres papers available for anonymous ftp
5. SQL server editing view with two tables "Row handle referred to a deleted row or
6. Tracing who delete the record?
7. Deleting from rows from more than one table
8. DAO Memory Leak using a simple Open and Close?
9. Need to delete rows from one table and put the in another
10. Better Perf: 1 table with 25,000,000 rows or 10 tables with 2,500,000 rows
11. Another Duplicate Rows, Delete All But One Row
12. using insert to add rows to tables froma table on another machine
13. Problem with adding rows to temp table from another table