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.
Author |
Topic |
jjz
Starting Member
31 Posts |
Posted - 2010-04-19 : 11:40:11
|
Good DayI am trying to convert a nvarchar to bigint and getting this error msg:Error converting data type nvarchar to bigint.Below is the piece of code i've used:select subnet,CAST(subnet as BIGINT)from IP_Subnet_TableThe field (subnet) does not have null valuesPlease assist. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-19 : 11:43:17
|
make sure you dont have any non numeric data in columntry this first and see if it worksselect subnet,CAST(subnet as BIGINT)from IP_Subnet_TableWHERE ISNUMERIC(subnet)=1 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-19 : 11:43:50
|
A fast shot:cast(replace(subnet,'.','') as BIGINT) No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
jjz
Starting Member
31 Posts |
Posted - 2010-04-19 : 11:45:36
|
This is the content of my field10.84.8210.85.3210.85.3310.85.3410.85.35 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-19 : 11:46:34
|
quote: Originally posted by jjz This is the content of my field10.84.8210.85.3210.85.3310.85.3410.85.35
how do you think you can convert this to bigint? the closest you can get isselect subnet,CAST(replace(subnet,'.','') as BIGINT)from IP_Subnet_Table ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-19 : 11:46:37
|
Then my fast shot was right. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
jjz
Starting Member
31 Posts |
Posted - 2010-04-19 : 11:49:16
|
thanx to both and yes Webfred your fast shot was spot on.thax |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-19 : 11:50:08
|
welcome No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
|
|
|