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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Conversion Issue in sql.

Author  Topic 

urzsuresh
Starting Member

30 Posts

Posted - 2010-12-23 : 23:39:54
Hi
Below one is model table, am getting strange issue, i dont know
how overcome this issue

Declare @t table
(
a numeric(4,2)
)
Declare @b varchar(4)
Set @b='2004'
Insert into @t
Select ISNULL(CONVERT(decimal(4,2),@b), 0)



In above things, working in trigger. Passing parameter is varchar type. we tried to insert varchar type to number type field. at the time am getting
error message.
Arithmetic overflow error converting varchar to data type numeric.
Even i tried to convert the varchar to numberic, and also am getting same issue.

Can any one please guide, how to convert the above one.

Suri

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-12-23 : 23:50:45
You need numeric(6,2). Numeric(4,2) only supports two digits to the left of the decimal place and two digits to the right. Numeric(6,2) would be 4 to the left and 2 to the right.

Declare @t table
(a numeric(6,2))
Declare @b varchar(4)
Set @b='2004'
Insert into @t
Select ISNULL(CONVERT(decimal(6,2),@b), 0)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -