GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Tech FAQs  >  SQL Server
Go To First  |  Previous Question  |  Next Question 
 SQL Server  |  Question 31 of 58    Print  
How to copy one table data into another table directly?

  
Total Answers and Comments: 3 Last Update: August 25, 2008     Asked by: penchal 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
October 12, 2007 06:14:13   #1  
chandra        

RE: How to copy one table data into another table dire...
Syntax to copy the structure of the one table into another table.

syn: select * into newtablename from oldtablename where false condition

ex: select * into dept1 from dept where 1=9

sytanx to copy one table data into another table.

syn:  insert into newtable name select * from old tablename

ex: insert into dept1 select * from dept.

 
Is this answer useful? Yes | No
November 15, 2007 00:40:00   #2  
srivani123 Member Since: November 2007   Contribution: 7    

RE: How to copy one table data into another table dire...
select into statement will work here

syntax: select column1,column2,....
into table2
from table1

 
Is this answer useful? Yes | No
August 25, 2008 01:06:38   #3  
sakthi.jaganathan Member Since: August 2008   Contribution: 8    

RE: How to copy one table data into another table directly?
We can copy the Table structure also from one table to another table

Example:
                   CREATE table emp1 as
                   SELECT * from emp
                   WHERE 1=2;

we can copy a data from one table to another table

While copying the data we should be careful in few things

1. Both the table Structure should be same

2. The DataType of all the Columns of the both table should be  same

Example:

                 INSERT INTO emp1 VALUES as
                 SELECT *
                 FROM emp




 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape