Tamer_Ahmed Posted September 14, 2004 Posted September 14, 2004 hi all well my problem is SQL Problem i have a table called employees let's say contain 100 row with 9 column now i add new column datatype bit now it will give the new column null value by default for the last 100 row well i want it to give those rows value 1 i tried default value but it's not work does anyone have an idea Quote
Administrators PlausiblyDamp Posted September 14, 2004 Administrators Posted September 14, 2004 If you are using MS SQL then you cannot create a new column that doesn't allow nulls, what you could do though is add the column, update the existing data i.e. UPDATE Employees set newcolumn =1 where newcolumn is null and then change the column to not allow nulls and also provide a default if required. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* Nerseus Posted September 14, 2004 *Experts* Posted September 14, 2004 If you use Enterprise Manager you can add the column with "NOT NULL" and put on the default at the same time. I generally go with Plausibly's solution though, as I don't usually want the default to stay. Plus, if it's an existing table I'll need to provide a script to update the real system since the "installers" won't want to go through the GUI. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.