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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:54:47+00:00 2026-05-16T08:54:47+00:00

I have a question, but let me first say that this is being performed

  • 0

I have a question, but let me first say that this is being performed on a database which I inherited and I am currently trying to improve the design on. Also the reason for the syntax is the fact that there are a lot of tables that the datatypes have been ‘tweaked’ by tech support people (/facepalm) causing lots of issues.

IF NOT EXISTS(Select * 
                FROM INFORMATION_SCHEMA.COLUMNS 
               WHERE TABLE_NAME = N'RXINFO' 
                 AND TABLE_SCHEMA = N'scriptassist' 
                 AND COLUMN_NAME = N'Price')
BEGIN

  Alter Table [scriptassist].[RXINFO] Add [Price] FLOAT
  Print 'Price Field  nonexistant creating this field'

END
ELSE
BEGIN
  If Not Exists(Select * 
                  From Information_Schema.Columns 
                 Where Table_Name = N'RXINFO' 
                   And Table_Schema = N'scriptassist' 
                   And Column_Name = N'Price'
                   And DATA_Type = N'FLOAT' 
                   AND IsNull(CHARACTER_MAXIMUM_LENGTH, 0) = 0)
  BEGIN

    Alter Table [scriptassist].[RXINFO] Alter Column Price FLOAT
    Print 'Price Field  needed type updating'

  END
END

Is what I am currently doing to determine if a column needs to be altered or added to a database. However even in the case of only having to add say 3-4 columns on a 500K-750K line database, where the table is about 100 columns wide, I’m estimating that this is taking anywhere from 15-20 minutes per column.

Things I have done to try to speed it up:

  • Removed the indexes before and then re-add after
  • Single user mode
  • ensured no connection to the database other than mine

I still don’t feel like it should be taking as long as it is, so my question is do I need to explicitly add the NULL after the column type for this to work as fast as I think it should?

  • 1 1 Answer
  • 1 View
  • 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-16T08:54:48+00:00Added an answer on May 16, 2026 at 8:54 am

    If you specifiy “NULL” or perhaps ‘NOT NULL WITH DEFAULT 0.0″ then only the schema will be updated and the rows in the table will not be altered, so the change will sub second for each table.

    If the column is NULLable it doesn’t have to be there so there is no need to update the rows when you alter the schema.

    If the column is not NULLable without a default then when you ALTER the schema to add the column every row in the existing table will be updated to add a column with the default default value of 0.0. This is why your alters take minutes.

    If you specify ‘NOT NULL WITH DEFAULT’ then the “DEFAULT” is added when the row is read so again there is no need to update the table rows.

    In both cases the current INSERT/UPDATE SQL will work without any changes. If you add a “NOT NULL” column with no default then current update SQLs will bomb out unless you add in the price column. This could be good thing or a bad thing depending on what you want to achieve.

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

Sidebar

Related Questions

This may be a newbie question, But let's say I have a database table
Maybe a basic question but let us say I have a string that is
First let me say that I really feel directionless on this question. I am
Let me first say that I realize this question is vague and does not
First, let me say that I have read other responses on this, and I
This is a pretty simple question really, but let's say I'm creating a model
This is for an Android application. Let's say that I have two colors with
Just a very general question, that not only applies to this example. Let's say
First of all let me say that this questions is slightly connected to another
I have this old question but no answer works for me from online, the

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.