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

  • Home
  • SEARCH
  • 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 95365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:38:48+00:00 2026-05-10T23:38:48+00:00

I have a column which has a datatype : datetime. But now i want

  • 0

I have a column which has a datatype : datetime. But now i want to convert it to datatype varchar. Can i alter the datatype without droppping the column? If yes, then please explain how?

  • 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. 2026-05-10T23:38:49+00:00Added an answer on May 10, 2026 at 11:38 pm

    If ALTER COLUMN doesn’t work.

    It is not unusual for alter column to fail because it cannot make the transformation you desire. In this case, the solution is to create a dummy table TableName_tmp, copy the data over with your specialized transformation in the bulk Insert command, drop the original table, and rename the tmp table to the original table’s name. You’ll have to drop and recreate the Foreign key constraints and, for performance, you’ll probably want to create keys after filling the tmp table.

    Sound like a lot of work? Actually, it isn’t.

    If you are using SQL Server, you can make the SQL Server Management Studio do the work for you!

    • Bring up your table structure (right-click on the table column and select ‘Modify’)
    • Make all of your changes (if the column transformation is illegal, just add your new column – you’ll patch it up in a moment).
    • Right-click on the background of the Modify window and select ‘Generate Change Script.’ In the window that appears, you can copy the change script to the clipboard.
    • Cancel the Modify (you’ll want to test your script, after all) and then paste the script into a new query window.
    • Modify as necessary (e.g. add your transformation while removing the field from the tmp table declaration) and you now have the script necessary to make your transformation.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a column in my table which has a DataType of 'timestamp'. Now
I have a column which has date-values stored in varchar (format ddmmyy) like this
For example, Lets say that I have a gridview column which has important controls,
I have a GridView on a .aspx page with a hidden column which has
I have a column called menu_order which has no default value. When I select
I have a table articles that has a column company which has list of
I have a table which has a column called Direct of type char(1). It's
I have a table which has a NVARCHAR column, which could contain a GUID
We have a Oracle 9i database and OrderDetails table which has a column to
I have a result of a query which has BLOB column defined in it.

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.