Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > error nvarchar value
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 10th July 05:20
brian
External User
 
Posts: 1
Default error nvarchar value



I keep getting this error when preforming a query
against a particular column. Anyone know how to get
around this?

Syntax error converting the nvarchar value '76499A' to a
column of data type int.

thx
  Reply With Quote


  sponsored links


2 10th July 05:20
vishal parkar
External User
 
Posts: 1
Default 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
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666