I am trying to convert varchar to bigint:
select convert(bigint, (select(Replace((select value from sometable), ' ', ''))))
Why is it giving error???
Error converting data type varchar to bigint.
thanks in advance
Update
This is part of query I am trying:
select top 1 *
into #tblTemp
from testTable
where Status = 0
order by Sno
declare @mobile varchar(50)
set @mobile = (select(Replace((select mobile from #tblTemp), ' ', '')))
--set @mobile = (select( Replace(' 9428017524', ' ', '')))
select convert(bigint, @mobile)
drop table #tblTemp
I am not sure what your real string is but for safety you can check
ISNUMERIC()before convertion.Just by reading your queries,
you don't need a temp tablehere at all. Everything can be done in a single query