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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:40:31+00:00 2026-06-04T01:40:31+00:00

I have a column which I believe has been declared wrongly. It contains data

  • 0

I have a column which I believe has been declared wrongly. It contains data and I do not wish to lose the data.

I wish to change the definition from varchar(max) to varchar(an integer). I was under the impression I cannot just alter the column type?

Is the best method to create a temp column, “column2”, transfer the data to this column, from the column with the problematic type, delete the problem column and then rename the temp column to the original problematic column?

If so, how do I copy the values from the problem column to the new column?

EDIT: For anyone with same problem, you can just use the ALTER statements.

  • 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-04T01:40:32+00:00Added an answer on June 4, 2026 at 1:40 am

    As long as the data types are somewhat “related” – yes, you can absolutely do this.

    You can change an INT to a BIGINT – the value range of the second type is larger, so you’re not in danger of “losing” any data.

    You can change a VARCHAR(50) to a VARCHAR(200) – again, types are compatible, size is getting bigger – no risk of truncating anything.

    Basically, you just need

    ALTER TABLE dbo.YourTable
    ALTER COLUMN YourColumn VARCHAR(200) NULL
    

    or whatever. As long as you don’t have any string longer than those 200 characters, you’ll be fine. Not sure what happens if you did have longer strings – either the conversion will fail with an error, or it will go ahead and tell you that some data might have been truncated. So I suggest you first try this on a copy of your data 🙂

    It gets a bit trickier if you need to change a VARCHAR to an INT or something like that – obviously, if you have column values that don’t “fit” into the new type, the conversion will fail. But even using a separate “temporary” new column won’t fix this – you need to deal with those “non-compatible” cases somehow (ignore them, leave NULL in there, set them to a default value – something).

    Also, switching between VARCHAR and NVARCHAR can get tricky if you have e.g. non-Western European characters – you might lose certain entries upon conversion, since they can’t be represented in the other format, or the “default” conversion from one type to the other doesn’t work as expected.

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

Sidebar

Related Questions

For each row I have a column which contains numbers like this 1,4,6,3,16,13 .
I have an xml column which contain data like this: <AuthorList CompleteYN=Y> <Author ValidYN=Y>
For example, Lets say that I have a gridview column which has important controls,
I have a table in MS Access, which has the following data to be
Hi I an issue with editors in a JTable. I have a column which
I have an options column which is serialized. I plan to store user preferences
I have a property column which can have a subset of the following values
How can I find all column values in a column which have trailing spaces?
I'm using MySQL and I currently have a VARCHAR column which stores times (in
I have a column in mysql which stores the dates. So in mysql 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.