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 |
|
footmaniac84
Starting Member
12 Posts |
Posted - 2011-05-11 : 11:59:46
|
| Hello,I want to add a new field that doesn't allow NULL and have a default value of 0 in a table.The problem is that this table is in use and have 200.000 rows.When i try to add this field, an error occurs because of the timeout...what can i do?Thank you. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-05-11 : 12:02:56
|
| How are you adding the column? Using ALTER TABLE, or DROP and CREATE? If you're running this in Management Studio you shouldn't be getting a timeout error. |
 |
|
|
footmaniac84
Starting Member
12 Posts |
Posted - 2011-05-11 : 12:57:07
|
| I am adding it with design view. I will try tomorrow to add it with a sql query.i will tell you the result.Thank you very much. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-05-11 : 13:04:22
|
| Yeah, read up on ALTER TABLE and do it that way. 200,000 rows is nothing unless you've got a very, very wide table on a very fragmented disk. |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2011-05-13 : 07:16:07
|
have a table dbo.Foo (Frst int, scnd char(3))insert into Foo select 1, 'sdr'union all select 2, 'etw'select * from Fooalter table foo add bar int default 0 with valuesselect * from foodrop table foo http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
footmaniac84
Starting Member
12 Posts |
Posted - 2011-05-19 : 05:41:40
|
| Perfect.Using alter table the time was less than two seconds....Thank you!. |
 |
|
|
|
|
|