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 263501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:36:25+00:00 2026-05-11T22:36:25+00:00

I understand that when adding a column to a table containing data in SQL

  • 0

I understand that when adding a column to a table containing data in SQL server, the column must have a NULL option or a default. Otherwise what would SQL Server pad the new rows with?

I am at a loss as to why I can’t add a NOT NULL column to an empty table however. I have tried this on two instances of SQL 2008 and one instance of SQL 2005 with no problems. However a customer with SQL 2000 does have this problem. Is this related to SQL 2000 or is it an option you can turn off. Let’s hope it’s an option.

Select @@Version

Microsoft SQL Server 2000 – 8.00.760 (Intel X86) Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows
NT 5.1 (Build 2600: Service Pack 3)

Select count(*) from actinv

0

ALTER TABLE [ActInv] ADD [BATCHNUMBER] NVARCHAR(50) NOT NULL

Msg 4901, Level 16, State 1, Line 1
ALTER TABLE only allows columns to be added that can contain nulls or have a
DEFAULT definition specified. Column ‘BATCHNUMBER’ cannot be added to table
‘ActInv’ because it does not allow nulls and does not specify a DEFAULT
definition.

  • 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-05-11T22:36:25+00:00Added an answer on May 11, 2026 at 10:36 pm

    SQL Server 2000 does not check for an empty table. What you are seeing is an improvement in SQL Server 2005/2008.

    Either of the following two step processes will make the change in SQL Server 2000 against an empty table:

    ALTER TABLE [ActInv] ADD [BATCHNUMBER] NVARCHAR(50) NOT NULL CONSTRAINT ActInv_Temp DEFAULT 'foo'
    ALTER TABLE [ActInv] DROP CONSTRAINT ActInv_Temp
    

    go

    ALTER TABLE [ActInv] ADD [BATCHNUMBER] NVARCHAR(50) NULL 
    ALTER TABLE [ActInv] ALTER COLUMN [BATCHNUMBER] NVARCHAR(50) NOT NULL 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 146k
  • Answers 146k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Desktop.open() launches the application associated with the extension of the… May 12, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer LINQ utilizes what we call deferred execution. When you write… May 12, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer To remove all the subviews from any view, you can… May 12, 2026 at 9:06 am

Related Questions

I understand that, in the interest of efficiency, when you query the database you
I have a DataSet with a DataTable that correctly fills a single DataRow through
I have a DataTable which is populated from a CSV file then, using a
I want to add the link tags to redirect my web-site to my OpenID

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.