If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Move Row from One table to Another

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-20-03, 22:32
Danial Danial is offline
Registered User
 
Join Date: Apr 2002
Posts: 8
Move Row from One table to Another

Hi,
Is there any way i can move a single row to from one table to another [same database].
Basically what i am trying to achive is this. I allow the user to delete a row, but instead of actuall deleting the row, i want to place it into another table [like a recycle bin], which can be restored later.

I know i can simply use insert into statement to add it to the 2nd table and perform the delete statement on table1, but it becomes very tedious becaus there are a lot of fields in my table. I am looking for some other efficient way, if its possible at all.

Any ideas and help is appriciated.

Thanks

Danial
Reply With Quote
  #2 (permalink)  
Old 10-21-03, 13:49
cmptrguru7 cmptrguru7 is offline
Registered User
 
Join Date: Feb 2002
Posts: 43
Re: Move Row from One table to Another

Quote:
Originally posted by Danial
Hi,
Is there any way i can move a single row to from one table to another [same database].
Basically what i am trying to achive is this. I allow the user to delete a row, but instead of actuall deleting the row, i want to place it into another table [like a recycle bin], which can be restored later.

I know i can simply use insert into statement to add it to the 2nd table and perform the delete statement on table1, but it becomes very tedious becaus there are a lot of fields in my table. I am looking for some other efficient way, if its possible at all.

Any ideas and help is appriciated.

Thanks

Danial
I think the only way to do this to do something like this:

INSERT INTO table2 SELECT * FROM table1 where row = row id.

this will allow you to select all fields without having to type them all. I think this is the most efficent way.
Reply With Quote
  #3 (permalink)  
Old 10-21-03, 23:15
Danial Danial is offline
Registered User
 
Join Date: Apr 2002
Posts: 8
Thumbs up

Thanks, Thats exactly what i was looking for.

Danial
Reply With Quote
  #4 (permalink)  
Old 04-29-12, 09:27
treypick treypick is offline
Registered User
 
Join Date: Oct 2010
Posts: 7
Code not working

Quote:
Originally Posted by cmptrguru7 View Post
I think the only way to do this to do something like this:

INSERT INTO table2 SELECT * FROM table1 where row = row id.

this will allow you to select all fields without having to type them all. I think this is the most efficent way.
I tried placing this code in a on click control button and could not get it to work. Am I inserting the code in the correct place.

Thanks Trwy
Reply With Quote
  #5 (permalink)  
Old 04-29-12, 14:24
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,511
Quote:
Originally Posted by treypick View Post
I tried placing this code in a on click control button and could not get it to work.
i'm sorry, i'm not familiar with the "could not get it to work" error message

Quote:
Originally Posted by treypick View Post
Am I inserting the code in the correct place.
i'm going to assume that you know that i can't see where in your code you inserted it, so i have to guess...

... and answer "probably you didn't"
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On