Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8549073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:38:31+00:00 2026-06-11T13:38:31+00:00

Let’s say there’s a table in SQL Server 2008 with two columns: id and

  • 0

Let’s say there’s a table in SQL Server 2008 with two columns: id and name. Now let’s say you want to add a non-nullable column to the table called “description”, and in the process of adding this column, you want to use the data in name as the original batch of data in description. Is there not a way to do this directly, i.e., without dropping the table and re-creating it or filling in the values manually post-addition or something? If there is a way, how? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:38:32+00:00Added an answer on June 11, 2026 at 1:38 pm

    You could what you’re asking as a computed column, but then you wouldn’t be able to later modify the description independently.

    What you can do to minimize the impact on the log etc. is to add it as nullable, then update the values in batches, then change it to not nullable.

    ALTER TABLE dbo.foo ADD description VARCHAR(whatever) NULL;
    
    SELECT 1;
    BEGIN TRANSACTION;
    
    WHILE @@ROWCOUNT > 0
    BEGIN
        COMMIT TRANSACTION;
        BEGIN TRANSACTION;
    
        UPDATE TOP (1000) dbo.foo 
          SET description = name
          WHERE description IS NULL;
    END
    
    ALTER TABLE dbo.foo ALTER COLUMN description VARCHAR(whatever) NOT NULL;
    
    COMMIT TRANSACTION;
    

    Or as Dems suggested, add it as not nullable with a default value, then later remove the default constraint.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have an Instant Messenger server using SignalR. I want to broadcast
Let's say I have such MYSQL table for logins: id---name---location---login_date ---------------------------------- 1----mike----usa-----21.08.2012 2----tony----uk------22.08.2012 3----tony----uk------23.08.2012
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have a table with a Color column. Color can have various
Let's say I have thousands of users and I want to make the passwords
Let's say I have two tables orgs and states orgs is (o_ID, state_abbr) and
Let's say I have window.open (without name parameter), scattered in my project and I
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say there is a graph and some set of functions like: create-node ::
Let's say after I had login I will be prompt to enter the Name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.