Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 copy table

Author  Topic 

mike009
Starting Member

15 Posts

Posted - 2006-03-20 : 01:19:45
hey
if i want to copy a table into totaly new table(that not created yet)

if i use the followin statement
create table studentcopy select * from student
i receive that there is error near 'select'

if i want use the following statement

insert into table studentcopy select * from student
in this case i got error that studentcopy table doesnot exist

i use MS SQL

how can i copy table to new table

if it is not possible and i have to create empty table first before
copying the content from the other table, then how can i return the structure of the original table to creat same table exactly
(mean how can i get the info of how the student table is created using qury)

thx

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-20 : 01:24:31
[code]select * into studentcopy table from student[/code]



KH

Choice is an illusion, created between those with power, and those without.
Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-20 : 01:31:58
If you use Select * into then the created table wont have the indices that source table has.
Create target table with the same structure of source table then apply this logic

insert into table studentcopy select * from student


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -