Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2008
    Posts
    4

    Unanswered: Converting a Field Type

    Hi All

    I have a field in a database that is set as Float. I want it to be a Varchar(4). I can't use a convert or cast command on the data in there as and when I need it because I have some data that will be imported on a regular basis which needs the field to be varchar.

    Is there a command to do this?

    Thanks in Advance

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    If you are certain you are not going to run into data truncation issues (remember ".0" counts as two characters), then you can use the ALTER TABLE command.
    Code:
    ALTER TABLE tablenamehere ALTER COLUMN columnnamehere VARCHAR(4)

    EDIT: You will also need to drop any indexes on this field, before you alter the column. You can recreate them later.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •