all groups > sql server (microsoft) > august 2005 >
You're in the

sql server (microsoft)

group:

TSQL Problem


TSQL Problem paulv0627 NO[at]SPAM hotmail.com
8/14/2005 10:07:42 PM
sql server (microsoft):
If I do this in Query Analyzer:

DECLARE @WORK INT

SET @WORK = (100 - 50) / 100


The result is zero. I've checked my SQL Server 2K (SP4) settings and
there's nothing obvious. Perhaps a fresh set of eyes can shed some
light on this.

Thanks

Re: TSQL Problem Ian
8/15/2005 2:11:47 AM
Hi Paul,

You need to declare your variable as a float if you want the decimals -
integers will not give you the result your are looking for.

Regards
Ian

[quoted text, click to view]
Re: TSQL Problem paulv0627 NO[at]SPAM hotmail.com
8/16/2005 4:29:20 AM
Thanks Ian

I had tried that with the only ttesults being more zeros. What did
work however was this:

SET @WORK = (100.000 - 50.000) / 100

I'm guessing I had to influence the intermediate results datatype to
be float. I'm still not sure if this is caused by a setting or not.
Regardless, thanks for your reply.

Best regards

Paul


[quoted text, click to view]
Re: TSQL Problem xAvailx
8/16/2005 10:42:49 AM
[quoted text, click to view]

Try SET @WORK = (100.000 - 50.000) / 100.000 << (Notice .000)

HTH
AddThis Social Bookmark Button