User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 397,850 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,345 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 763 | Replies: 3 | Solved
Reply
Join Date: Apr 2007
Posts: 246
Reputation: greeny_1984 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 9
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz in Training

need query help

  #1  
Jul 18th, 2007
how to write a query to insert a row that is deleted from one table to another table using sql server 2000 at the same time
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2007
Posts: 246
Reputation: greeny_1984 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 9
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz in Training

Re: need query help

  #2  
Jul 18th, 2007
got the answer
insert table_name1(col1,col2,...) select col1,col2,... from table_name2
Reply With Quote  
Join Date: Aug 2006
Location: India
Posts: 812
Reputation: arjunsasidharan is on a distinguished road 
Rep Power: 4
Solved Threads: 13
arjunsasidharan's Avatar
arjunsasidharan arjunsasidharan is offline Offline
Practically a Posting Shark

Re: need query help

  #3  
Jul 19th, 2007
or
insert into table_name2
select col1,col2 from table_name1
There is just two ways to live your life.
One is as though nothing is a miracle.
The other is as if everything is.
Reply With Quote  
Join Date: Feb 2007
Location: Bangalore,India
Posts: 1,213
Reputation: debasisdas is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 78
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Nearly a Posting Virtuoso

Re: need query help

  #4  
Jul 21st, 2007
what if the the table2 contains more/different columns than the table1 ?
you have to specify the column name
Your code will work if both the tabels are having same structure.
Share your Knowledge.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 8:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC