Showing posts with label remember. Show all posts
Showing posts with label remember. Show all posts

Monday, February 13, 2012

arithmetic operations with money and real

Hallo,
as far as I remember the result of an arithmetic operation
in SQL Server 2000 is implicitly casted to the higher ranked
data type.
In SQL Server 7.0 real is higher than money so that every
multiplication or divison of a money and real value is real.
I think this is valid for SQL Server 2000 too.
My new project includes some very high money values and I
have a lot of multiplications (percentage up to 100) and
divisions (by rates of exchange).
So is it a good idea to cast explicitly every real value to
a money value in arithmetic operations like?
Klaus
www.trappdata.dehi,
you must be aware that when you do something with real datatype, in some
cases you may loose precision. even if it is a cent, it may matter to
someone.
peter
"Klaus Trapp" <Klaus.Trapp@.gmx.de> wrote in message
news:uKnj9hFSGHA.1780@.TK2MSFTNGP12.phx.gbl...
> Hallo,
> as far as I remember the result of an arithmetic operation
> in SQL Server 2000 is implicitly casted to the higher ranked
> data type.
> In SQL Server 7.0 real is higher than money so that every
> multiplication or divison of a money and real value is real.
> I think this is valid for SQL Server 2000 too.
> My new project includes some very high money values and I
> have a lot of multiplications (percentage up to 100) and
> divisions (by rates of exchange).
> So is it a good idea to cast explicitly every real value to
> a money value in arithmetic operations like?
>
> Klaus
> www.trappdata.de|||Klaus,
Money and real?. This is not a good combination because real is an
approximate number.
See is this can help.
monney vs numeric
http://groups.google.com/group/micr...r />
t=0&num=3
AMB
"Klaus Trapp" wrote:

> Hallo,
> as far as I remember the result of an arithmetic operation
> in SQL Server 2000 is implicitly casted to the higher ranked
> data type.
> In SQL Server 7.0 real is higher than money so that every
> multiplication or divison of a money and real value is real.
> I think this is valid for SQL Server 2000 too.
> My new project includes some very high money values and I
> have a lot of multiplications (percentage up to 100) and
> divisions (by rates of exchange).
> So is it a good idea to cast explicitly every real value to
> a money value in arithmetic operations like?
>
> Klaus
> www.trappdata.de
>

Thursday, February 9, 2012

Are stored procedures more performant than on the fly sql?

Hello.

I've read the other day (don't remember where :( ) that there is no performance advantages on executing stored procedures than executing sql strings made "on the fly". It said that both operations are precompiled on first execution, and then cached to posterior executions... Is that correct?

Thanks in advance,
Matias

Yes they are as compared to the normal TSQL statements provided the stored procedures a recompiled whenever they are modified for update of cache plan.

You need to refer to the books online and these links http://www.sql-server-performance.com/tn_stored_procedures.asp and http://www.awprofessional.com/articles/article.asp?p=25288 to know more about SPs.

|||

Satya,

your answer is a bit confusing....

are you saying that Stored Procedures ARE faster then on the fly SQL ? or are you saying they are NOT ?

my understanding is that they ARE especially when the SQL is more complex.

This is not the only reason to use sprocs however, other reasons are improved security, improved maintainability and modularity, etc.

cheers,

|||

Yes, I thought that too. Does sql 2005 precompiles and caches text t-sql statements, making them as performant as stored procedures on subsequent calls? I'm not discussing all the advantages of using stored procedures vs on the fly sql, I just want to know if there is any performance penalty using on the fly sql.

Thanks,
Matias

|||

as per this article, "ALL" Sql Statements are cached\precompiled.

http://msdn2.microsoft.com/en-us/library/ms181055.aspx

so that would suggest that there may NOT be a huge performance issue in using sprocs.

The argument to use sprocs for Security and maintainability is more viable.

It would be fairly easy to test this use SQL Profiler......

cheers