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)
 Creating a table by copying from another

Author  Topic 

rohcky
Starting Member

38 Posts

Posted - 2005-04-22 : 09:51:21
I'm having trouble creating tables in a DTS (which shouldn't be any different from any other way). I need to create a table that has the exact structure and records (record not as important as structure) as another table.

I've tried the sql string:
CREATE TABLE <new_tbl_name> SELECT * FROM <old_tbl_name>

but all i get is a syntax error message when trying to run. Anyone know the correct way of doing this? I've been trying to figure this out for days.

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2005-04-22 : 10:01:02
Is this what you are after

SELECT * INTO <new_tbl_name> FROM <old_tbl_name>

Andy

Beauty is in the eyes of the beerholder
Go to Top of Page

rohcky
Starting Member

38 Posts

Posted - 2005-04-22 : 10:08:32
You are awesome man. I've been searching the net for the answer and all I got was that first sql string that didn't work. You're a life saver Andy!
Go to Top of Page

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2005-04-22 : 10:24:11
You obviously didnt come here first or read BOL (SELECT Clause)

Beauty is in the eyes of the beerholder
Go to Top of Page

chasBoy
Starting Member

1 Post

Posted - 2005-05-12 : 05:57:03
Thanks Andy
Go to Top of Page
   

- Advertisement -