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.
Author |
Topic |
bootsy
Starting Member
7 Posts |
Posted - 2008-03-05 : 13:17:13
|
I need to duplicate the structure of a table. I don't need the data. But I need to have the exact same field names and data types. How do I duplicate a table? |
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2008-03-05 : 13:31:53
|
INSERT INTO (...)SELECT ....FROM SourceTableWHERE 1=0Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
bootsy
Starting Member
7 Posts |
Posted - 2008-03-05 : 13:44:58
|
Thank you but it didn't work. I tried this: INSERT INTO (dbo.May_2006_Parse)SELECT ....FROM dbo.April_2005_ParseWHERE 1=0This is the error I get;Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near '('.Server: Msg 156, Level 15, State 1, Line 3Incorrect syntax near the keyword 'FROM'.I'm extremely new to SQL. Can you bare with me please? |
 |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-03-05 : 14:16:13
|
select top 0 * into dbo.May_2006_Parse from dbo.April_2005_ParseBut it would be better to just script the table create statement, that way you get indexes, constraints, etc."God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
bootsy
Starting Member
7 Posts |
Posted - 2008-03-05 : 15:00:28
|
Thanks jhocutt. It works beautifully! Thank you everyone for all your help. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-03-06 : 08:15:53
|
quote: Originally posted by bootsy Thank you but it didn't work. I tried this: INSERT INTO (dbo.May_2006_Parse)SELECT ....FROM dbo.April_2005_ParseWHERE 1=0This is the error I get;Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near '('.Server: Msg 156, Level 15, State 1, Line 3Incorrect syntax near the keyword 'FROM'.I'm extremely new to SQL. Can you bare with me please?
You should have triedselect * into dbo.May_2006_Parse from dbo.April_2005_Parsewhere 1=0MadhivananFailing to plan is Planning to fail |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-03-06 : 08:52:57
|
Do you really need to put each month in it's own table? Why are you doing this? All of your data that is of the same type should be in one single table, with a a simple "month" column to indicate which month each row belongs to.- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
|
|
|
|