Click here to Skip to main content
15,917,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to change datatype bit to int in sql server 2008
Posted
Updated 15-Jun-12 2:50am
v2
Comments
Prasad_Kulkarni 23-May-12 9:06am    
20008???
Wendelius 23-May-12 14:47pm    
That's going to be released a few years from now, just a bit after Mr Gates is defrosted from cryo chamber :)
Tim Corey 15-Jun-12 8:50am    
Could you please accept one or more of the answers below so that this question is closed out? Thanks.

There is a data type called 'tiny int' in sql server which is equivalent to bit or byte.. You could use Cast or Convert function in TSQL to convert the value to int or small int etc

Please refer the link below

http://msdn.microsoft.com/en-us/library/ms187928.aspx


If you want to Alter the table itself converting from byte to Int will not have any problems as you are adding more bytes to the same value.. Only from int to bit will be a problem (values will be truncated)..
 
Share this answer
 
v2
You can easily do this using the following command.
SQL
ALTER TABLE dbo.YourTable ALTER COLUMN YourColumnName INT
 
Share this answer
 
v2
Comments
Wendelius 23-May-12 15:06pm    
Good answer, just corrected a small typo :)
Prasad_Kulkarni 23-May-12 23:49pm    
Thank you :)
SQL
Try:
ALTER TABLE table_name ALTER COLUMN column_name INT


Other option is to create new column of type INT, populate this field with existing BIT column & drop old column once you are done.

This will be safe in case you want to see the data before you actually drop the original column..
 
Share this answer
 
Try to this

ALTER TableName ALTER COLUMN ColumnName INT
 
Share this answer
 
check out this article to alter table.

http://www.gigasters.com/post.aspx?postid=18[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900