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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-04-22 : 09:09:47
|
| Prajakta writes "I want to create a new empty table with same structure as another table. Thne i would like to change the datatype of one fiels in this new table. After this finally transfer the data from first table into new table." |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-04-22 : 09:16:59
|
OKJust do it Firstly, why not just manually create a table ?But I know you are going to find some reason why you can't do it. So....Create the blank table by using a Select IntoSelect *Into MyNewTableFrom MyOldTableWHERE 1=0 --this will return 0 rowsThen alter the table and columnAlter Table MyNewTableAlter Column MyColumn varchar(30) --or whatever your new datatype isthen copy the dataInsert Into MyNewTableSelect * From MyOldTableThat should do itDamian |
 |
|
|
rrb
SQLTeam Poet Laureate
1479 Posts |
Posted - 2002-04-23 : 20:19:22
|
And don't forget you could also just do select column1, column2, CAST(column3 as NewType)into MyNewTablefrom MyOldTable[/b] --I hope that when I die someone will say of me "That guy sure owed me a lot of money" |
 |
|
|
|
|
|