Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2003
    Posts
    11

    Question Unanswered: Convert Money to Varchar(50)

    I created a table using sql, and I accidentally made one of the fields a money datatype and I meant to make it a Varchar(50). Is there an easy way to change the datatype with an sql update/convert statement. I want to make the change permanent. As I need it to reflect on a couple of different databases with this same table name. Here is the update statement I have been trying.

    update ibapoorderline set salestype=convert(varchar(50),salestype)

    There is currently no data stored in the column salestype. They are all null. I just want to change the datatype so I can begin adding data.

    Thanks in advance.

  2. #2
    Join Date
    Feb 2003
    Posts
    15
    Drop the column and re-add it.

    create table f00 (f00id int, f00monex money)
    go
    --whoops!
    alter table f00 drop f00monex
    go
    alter table f00 add f00varchar varchar(50) NULL
    go


    Convert will only convert the data for output, it won't change the datatype of the column.

  3. #3
    Join Date
    Feb 2003
    Posts
    11
    Thank you so much. What I was looking for was the drop line. That helps a lot. I couldn't remember how to get rid of a column and then add it back in with a different datatype.

  4. #4
    Join Date
    Feb 2003
    Posts
    15
    No problem. Note that when you drop/add it moves the column to the bottom of the column list. Not sure if you care about that...

    Look up ALTER TABLE in Books Online for more syntax.

Posting Permissions

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