Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 converting varchar to int

Author  Topic 

rameshgoudd
Starting Member

13 Posts

Posted - 2008-02-28 : 23:17:40
hi all.

in my database i have two fields ..aprsal and datatype is varchar(100)
second field is maysal datatype is varchar(100)

i want to add these values after converting in to the int

how can i do this in sql

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-02-28 : 23:21:49
select convert(int, aprsal) from mytable


elsasoft.org
Go to Top of Page

dineshasanka
Yak Posting Veteran

72 Posts

Posted - 2008-02-29 : 04:41:22
Or
SELECT CAST(aprsal as int)

---------------------
http://dineshasanka.spaces.live.com/
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-29 : 04:46:03
if the nature of the data is integer, why not use integer or decimal data type to store it instead of varchar ?

And why are you storing the 12 month salary in 12 column ? Shouldn't you normalize this ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -