Showing posts with label places. Show all posts
Showing posts with label places. Show all posts

Friday, March 30, 2012

predicate using xml in sql server 2005

Hi ,
I have a doubt using xml in sql sever 2005.
I found in many places while specifying Xpath ,the predicate contains '1'
like
/Inst:root/Inst:Location[1]/Inst:step .
I tried with some other numbers in predicate like
/Inst:root/Inst:Location[2]/Inst:step .i got null value.
Can u plz explain me what is it doing.
thx.
priya.The square brackets are an abbreviation of the position() XPath function.
E.g.:
/Inst:root/Inst:Location[1]/Inst:step
equals to
/Inst:root/Inst:Location[position() = 1]/Inst:step
Return the Inst:step child-node of the first Inst:Location node in the
Inst:root node. A null value for /Inst:root/Inst:Location[2]/Inst:step means
that there is either only one Inst:Location node or there is no Inst:step
node on the second Inst:Location.
ML
http://milambda.blogspot.com/

Wednesday, March 28, 2012

Precision Problem

Hi,

I can't seem to get a stored procedure to return decimal places. Here are the steps to re-create the problem:

--first create the following procedure
CREATE PROCEDURE test_precision
AS
BEGIN
RETURN 5.2
END

--then run the following code
DECLARE @.x DECIMAL(18,2)
EXECUTE @.x = test_precision
SELECT @.x

I would like this code to return 5.20, but instead it returns 5.00. Any assistance would be greatly appreciated. Thanks.if you are using SQL 2005 that is the problem. Your stored Procedure would work correctly in SQL 2000.

The work around
declare @.x FLOAT(18,2)

give that a try.|||ooops!! allow me to take that back - wrong thought process. sorry.

you need to edit your proc to read 5.20sql

Precision on Money data type

How do I set the precision on the money data type in SQL Server. I want it to display only 2 decimal places and get rid of any more than that id someone tries to insert more without throwing an error.

Example:

i input 10.5432

It makes it 10.54
automatically.

If this is not possible, can I at least put in an amount like 10.56 and not have the database automatically turn this into 10.5600

Please help::How do I set the precision on the money data type in SQL Server.

Tried the documentation? Mean, this is so obvious that I would look there first.

Let me quote from "money data type / overview":

::Monetary data values from -2^63 (-922,337,203,685,477.5808) through
::2^63 - 1 (+922,337,203,685,477.5807), with accuracy to a ten-thousandth of a monetary
::unit. Storage size is 8 bytes.

::I want it to display only 2 decimal places and get rid of any more than that id someone
::tries to insert more without throwing an error.

Welcome to programming. YOu have to do so in your input layer.

::If this is not possible, can I at least put in an amount like 10.56 and not have the database
::automatically turn this into 10.5600

You can us an insert / update trigger to round the values. I would normally handle this i n the business objects :-)|||Use decimal instead of money. You can exactly specify the precision and scale|||Thanks Dutch,... I appreciate that