Unix Technical Forum

Conversion Probs..

This is a discussion on Conversion Probs.. within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi Group, I am trying to display the multiplication through this way ---------------------- select 1163436036*100 ---------------------- Getting the error ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 08:52 AM
arijitchatterjee123@yahoo.co.in
 
Posts: n/a
Default Conversion Probs..

Hi Group,
I am trying to display the multiplication through this way
----------------------
select 1163436036*100
----------------------
Getting the error
============================
Server: Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.
============================
For that reason I was tried to convert that to nvarchar
------------------------
select convert(numeric(36,2),1163436036*100)
------------------------
But still getting the error
=============================
Server: Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.
=============================
Please help me to solve it out..
Thanks and Regards
Arijit Chatterjee

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 08:52 AM
Erland Sommarskog
 
Posts: n/a
Default Re: Conversion Probs..

(arijitchatterjee123@yahoo.co.in) writes:
> Hi Group,
> I am trying to display the multiplication through this way
> ----------------------
> select 1163436036*100
> ----------------------
> Getting the error
>============================
> Server: Msg 8115, Level 16, State 2, Line 1
> Arithmetic overflow error converting expression to data type int.
>============================
> For that reason I was tried to convert that to nvarchar
> ------------------------
> select convert(numeric(36,2),1163436036*100)
> ------------------------
> But still getting the error
>=============================
> Server: Msg 8115, Level 16, State 2, Line 1
> Arithmetic overflow error converting expression to data type int.
>=============================
> Please help me to solve it out..


You need to convert one of the numbers in the expression to the
target type you want, for instance:

select 1163436036*convert(bigint, 100)

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 08:52 AM
Dan Guzman
 
Posts: n/a
Default Re: Conversion Probs..

> Arithmetic overflow error converting expression to data type int.

This error message provides the clue as to the underlying cause. You get an
integer result when you multiply 2 integers (1163436036*100) before the
CONVERT. You'll get a numeric(36, 2) result if you CONVERT or CAST at least
one of the values to numeric(36, 2):

SELECT CONVERT(numeric(36,2), 1163436036)*100
SELECT CAST(1163436036 AS numeric(36,2))*100

Since both of the values are integers, you might consider using bigint
instead of numeric if your are using SQL Server 2000:

SELECT CONVERT(bigint, 1163436036)*100
SELECT CAST(1163436036 AS bigint)*100

--
Hope this helps.

Dan Guzman
SQL Server MVP

<arijitchatterjee123@yahoo.co.in> wrote in message
news:1118148077.784344.140590@g43g2000cwa.googlegr oups.com...
> Hi Group,
> I am trying to display the multiplication through this way
> ----------------------
> select 1163436036*100
> ----------------------
> Getting the error
> ============================
> Server: Msg 8115, Level 16, State 2, Line 1
> Arithmetic overflow error converting expression to data type int.
> ============================
> For that reason I was tried to convert that to nvarchar
> ------------------------
> select convert(numeric(36,2),1163436036*100)
> ------------------------
> But still getting the error
> =============================
> Server: Msg 8115, Level 16, State 2, Line 1
> Arithmetic overflow error converting expression to data type int.
> =============================
> Please help me to solve it out..
> Thanks and Regards
> Arijit Chatterjee
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 08:53 AM
arijitchatterjee123@yahoo.co.in
 
Posts: n/a
Default Re: Conversion Probs..

Thanks,
Thanks for your great support.
Regards
Arijit Chatterjee

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:58 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com