| Author |
Topic |
|
svicky9
Posting Yak Master
232 Posts |
Posted - 2005-08-04 : 15:42:29
|
| Hi i want to create a duplicate table in t-sql with the same column fields in but no data in it Can anyone help meI remember in Oracle u can do it likecreate table duplicate as select * from original_table where 1 = 2with the false condition we can create a table with the same columnsI tried the same with t-sql but i cannot do it.Can anyone tell me how to do it...ThanksVickyVicky |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
svicky9
Posting Yak Master
232 Posts |
Posted - 2005-08-04 : 16:52:39
|
| thank youVicky |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-05 : 03:12:57
|
| >>SELECT * INTO NewTable FROM OldTable WHERE 1=0It should be noted that Newtable wont have any indexesThe best way is Generate table script of Oldtable and rename the table name and run itMadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-08-05 : 08:51:42
|
quote: Originally posted by madhivananThe best way is Generate table script of Oldtable and rename the table name and run it
What if the table has a billion rows?The answer is always...it depends...and since we don't know what they're trying to accomplish, that goes double.MOOBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-05 : 08:56:55
|
| >>What if the table has a billion rows?I dont think number of rows matters when generating script of a tableDo you think there is performance issue?MadhivananFailing to plan is Planning to fail |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-05 : 09:26:13
|
Not fully returned from Cruise MadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-08-05 : 09:40:01
|
"I forgot that they didn't want the data....."Blimey! Loads of grey cells must have gone bye-bye for you to forget overnight that you typedSELECT * INTO NewTable FROM OldTable WHERE 1=0 Kristen |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|