error nvarchar value
hi brian,
This is because you are trying to convert a value that contains alphabets to
numeric, which will obviously give you an error. see following example for the
reason and workaruond.
Ex:
create table #t
(col1 nvarchar(15))
insert into #t values ('76499A' )
insert into #t values ('76499' )
--following query will give error because value 76499A can not be converted to
int. since it contains alphabets.
select cast(col1 as int)
from #t
-- to convert only propoer numeric value you can use function ISNUMERIC and
have query as follows.
select cast(col1 as int)
from #t
where isnumeric(col1) = 1
-- Vishal
|