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 |
|
Sean_B
Posting Yak Master
111 Posts |
Posted - 2009-06-09 : 09:46:07
|
| Hi,I'm running the following code to change a column from varchar to int. This is taking a very long time to update the 95 million rows in the table. Is there another way of doing this, perhaps altering the column definition ? --alter table trade add temptflag intupdate trade set temptflag = cast(tflag as int)alter table trade drop column tflagEXEC sp_rename 'trade.temptflag', 'tflag', 'COLUMN';--Sean |
|
|
Sean_B
Posting Yak Master
111 Posts |
Posted - 2009-06-09 : 11:42:15
|
| doing it in batches in a loop seems o be the answer.Sean |
 |
|
|
asgast
Posting Yak Master
149 Posts |
Posted - 2009-06-09 : 12:05:54
|
| books online say that you can change the type directly, without using buffer column, have you tried it?http://msdn.microsoft.com/en-us/library/ms190273.aspx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-09 : 12:08:54
|
quote: Originally posted by Sean_B Hi,I'm running the following code to change a column from varchar to int. This is taking a very long time to update the 95 million rows in the table. Is there another way of doing this, perhaps altering the column definition ? --alter table trade add temptflag intupdate trade set temptflag = cast(tflag as int)alter table trade drop column tflagEXEC sp_rename 'trade.temptflag', 'tflag', 'COLUMN';--Sean
is there any existing index on column? |
 |
|
|
|
|
|