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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:45:07+00:00 2026-06-04T13:45:07+00:00

I have a table in SQL Server 2008 R2 with close to a billion

  • 0

I have a table in SQL Server 2008 R2 with close to a billion rows. I want to change the datatype of two columns from int to bigint. Two times ALTER TABLE zzz ALTER COLUMN yyy works, but it’s very slow. How can I speed the process up? I was thinking to copy the data to another table, drop, create, copy back and switching to simple recovery mode or somehow doing it with a cursor a 1000 rows a time but I’m not sure if those will actually lead to any improvement.

  • 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-04T13:45:09+00:00Added an answer on June 4, 2026 at 1:45 pm

    Depending on what change you are making, sometimes it can be easier to take a maintenance window. During that window (where nobody should be able to change the data in the table) you can:

    1. drop any indexes/constraints pointing to the old column, and disable triggers
    2. add a new nullable column with the new data type (even if it is meant to be NOT NULL)
    3. update the new column setting it equal to the old column’s value (and you can do this in chunks of individual transactions (say, affecting 10000 rows at a time using UPDATE TOP (10000) ... SET newcol = oldcol WHERE newcol IS NULL) and with CHECKPOINT to avoid overrunning your log)
    4. once the updates are all done, drop the old column
    5. rename the new column (and add a NOT NULL constraint if appropriate)
    6. rebuild indexes and update statistics

    The key here is that it allows you to perform the update incrementally in step 3, which you can’t do in a single ALTER TABLE command.

    This assumes the column is not playing a major role in data integrity – if it is involved in a bunch of foreign key relationships, there are more steps.

    EDIT

    Also, and just wondering out loud, I haven’t done any testing for this (but adding it to the list). I wonder if page + row compression would help here? If you change an INT to a BIGINT, with compression in place SQL Server should still treat all values as if they still fit in an INT. Again, I haven’t tested if this would make an alter faster or slower, or how much longer it would take to add compression in the first place. Just throwing it out there.

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

Sidebar

Related Questions

I use SQL Server 2008 and have a table with 5 char typed columns.
In SQL Server 2008: I have one table, and I want to do something
I'm using SQL Server 2008 and I have a table with three columns: Length
I have a staging table (in SQL SERVER 2008) with nullable fields. I want
This is on SQL Server 2008. I have several columns I want to convert
I have SQL Server 2008 database with 2 tables: Table A has columns ID
In SQL Server 2008 R2, I have to compare two dates of birth from
I have a table in SQL Server 2008 with columns serial, ida, idb ,
I'm using SQL Server 2008 and I have a table that has a 'Status'
I have a table named myTable on SQL Server 2008 R2 Express. I would

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.