Sunday, February 12, 2012

cant increase column size

hey

i've a db running sql server express sp2. the db size now is 1.1 gb
i've a table with a varchar column of size 20 . when i try to increase the column size to 50 i get a
timeout exception, and the the cloumn size is unchanged. this table has 2.5 million records

i use sql server management studio express to do the changes

is there a way to increase this timeout or whtever i can do to update this column size?

thx in advance

I am guessing you are using ssms and the GUI to edit this column. There are occasions when you use the GUI that sql server doesn't choose the most efficient way of executing a task. In this instance, i would hazard a guess that it will be creating a temp table with the new schema and then dumping the records in to it before dropping your table and renaming the new temp one to the original one. (stay with me!!)

If you just try,

ALTER TABLE tbl
ALTER COLUMN col1 VARCHAR(50)

Hopefully, that will be quicker.

|||well strangely thats actually works
weird how the gui can be soo stupid in such a simple task

thx man
|||

There is subtle difference doing this task from GUI and from T-SQL.


From T-SQL:


It alters the existing table to modify that column alone.


From GUI:


1) Creates a new tmp table with the new structure and inserts the data from the table you are modifying with insert select clause.


2) Drops the table you are modifying.


3) Renames the new tmp table to the old table's name.


You could see this for yourself if you turn on SQL Profiler and try to modify the table with T-SQL and from GUI.

No comments:

Post a Comment