Can I change a column from smallint to float?

  • I've got a column, in 1 table, that's a smallint. Then I've got another table with the same column name (it's meant to be the same thing) but it is a float. I'd really like to change the data type in the first table to a float, too, but am concerned that I might loose data. May I just change the data type from smallint to float, and will SQL Server 2008 R2 keep my data?

    Rod

  • yes

  • What does the column hold? If the smallint holds all the appropriate values, I'd go the other way, making the float into a smallint. Float is an approximate data type, so there are interesting issues that can crop up with its usage when not properly applied.


    And then again, I might be wrong ...
    David Webb

  • Yes, SQL Server will retain the values when you change the data type.

    Mark

  • I think David is on to something here. If both columns are meant to be the same and they actually do hold smallint data, then convert the float column to a smallint data type. Your table size will be smaller and you won't suffer from the approximate data type.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply