Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • *Experts*
Posted

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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...