datatype change question

  • If I want to change the datatype of a column from one datatype to another for ex.

    changing from int to decimal, what procedure should I follow. Ofcourse I shall first do the

    change in dev environment and then test it thoroughly, before making the change in

    production environment. We have sql 2005 db and the front end is a .net application.

    Please advice. Thanks!

  • Run Alter table tabName Alter column columnName Newdatatype in mgmt. studio and it will take time based on the records count in the table.

    MJ

  • Thanks for the reply. Will there be any data loss by changing the data type? I am trying to prepare if

    we need to do anything different so that there is no data loss when done in production

    environment.

  • As stated above, you can use management studio to perform the action.

    However, more interesting is to let SSMS generate the SQL to complete the action.

    Doing so, you'll see SQLserver encapsulates the operation in a transaction !

    That is actually one of the nicest features of SSMS, you can learn very much by investigating what it does to handle your stuff.

    You should check you current data still fits the requisites of the desired datatype or you will get a runtime error.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

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

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