sql server - How to change column datatype in SQL database without losing data -


i have sql server database , realized can change type of 1 of columns int bool.

how can without losing data entered table?

you can using following command. value of 0 turned 0 (bit = false), else turned 1 (bit = true).

alter table dbo.yourtable    alter column yourcolumnname bit 

the other option create new column of type bit, fill old column, , once you're done, drop old column , rename new 1 old name. way, if during conversion goes wrong, can go since still have data..


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -