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 |
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2009-05-05 : 09:45:45
|
| Hi i have a query in the form"IF NOT EXISTS ( SELECT 1 FROM syscolumns WHERE name = 'chip' AND id=object_id('dbo.Log') )BEGINALTER TABLE Log ADD chip BIT DEFAULT 0END"its adding the column but its not setting the value to default .how can i accomplish this in the same alter statement .Can anyone help me urgent.similarly i have column with defualt as getdate ,identity(1,1) even that not workingsusan |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-05-05 : 10:18:16
|
| It is effecting when data are added newlyTo update data which are already available, you need to update themMadhivananFailing to plan is Planning to fail |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-05-05 : 10:19:16
|
| The syntax looks right to me. Is your problem that the existing rows are not showing the default value specified ? Specifying default won't affect the rows which are already in the table. It'll be defaulted with every insert after you alter the table. |
 |
|
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2009-05-05 : 10:28:56
|
| Ok thank you sakets am able to get what u r trying to tellsusan |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-05-05 : 12:25:13
|
| also try adding [ WITH VALUES ] to your alter statement.[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQL or How to sell Used CarsFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|
|