Thursday, April 2, 2015

Conversion from Varchar to INT in SQL Server

Whenever you want to convert a VARCHAR to INT in SQL Server you can use CONVERT function.

Lets assume we are using the below table :


















The table columns have below data types:























We have to convert the seat_no of varchar datatype from varchar to INT to calculate the students with seat number greater than 5.


we can use query :
  select * from chinook.dbo.student
  where convert(int,seat_no) > 5  to calculate the results. Like INT we can also use CONVERT(Float,seat_no)





No comments:

Post a Comment