soozh
asked on
SQL / xml / real conversion problem
MS SQL Server 2008.
I have a stored procedure that recieves and xml document and uses it to update a table.
I have a line of code:
It works when the value of Tumorhojd is a number that has a decimal point, but not when it contains a decimal comma.
We are using decimal comma's in our data.
Is there a way to set up the conversion so that decimal comma is accepted?
Thanks
I have a stored procedure that recieves and xml document and uses it to update a table.
I have a line of code:
[Tumorhojd] = @xmlData.value('(BRUM-registret/OriginalData2012/Tumorhojd)[1]', 'real'),
that updates a REAL column.It works when the value of Tumorhojd is a number that has a decimal point, but not when it contains a decimal comma.
We are using decimal comma's in our data.
Is there a way to set up the conversion so that decimal comma is accepted?
Thanks
ASKER
Yes i could do that but i was wondering how i could change the database/server settings to use decimal comma.
I believe that cannot be done (atleast upto my knowledge).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok how would you store "real" data. By that i mean data with a decimal point(or comma).
And how do countries that use decimal comma (and i Think that is most of Europé) handle this problem? MS SQL Server must be set up for the "Locale" just like windows can be?
And how do countries that use decimal comma (and i Think that is most of Europé) handle this problem? MS SQL Server must be set up for the "Locale" just like windows can be?
decimal points are accepted, but the commas are not accepted as part of real or decimal data types
ASKER
what i mean is that if i convert a real to a varchar i would expect it to contain a decimal comma in the countries that use decimal comma, and decimal Point in the countries that use decimal Point....
and it should be configurable... that sounds resonable... you cant expect the french to use decimal Point..
and it should be configurable... that sounds resonable... you cant expect the french to use decimal Point..
ok how would you store "real" data. By that i mean data with a decimal point(or comma).
Both Real and Float are approximate numeric data types and should only be used for scientific or astronomic data. That is unless you are OK with $10.23 represented as 10.230000001 or 10.2299999991. You are better off using numeric (or decimal) or money or smallmoney data types to represent decimal values as they are exact.
And how do countries that use decimal comma (and i Think that is most of Europé) handle this problem?
This is handled at the application level. SQL Server does not store values with decimal points or decimal commas.
Both Real and Float are approximate numeric data types and should only be used for scientific or astronomic data. That is unless you are OK with $10.23 represented as 10.230000001 or 10.2299999991. You are better off using numeric (or decimal) or money or smallmoney data types to represent decimal values as they are exact.
And how do countries that use decimal comma (and i Think that is most of Europé) handle this problem?
This is handled at the application level. SQL Server does not store values with decimal points or decimal commas.
ASKER
This is handled at the application level. SQL Server does not store values with decimal points or decimal commas.
I understand..but if i have a stored procedure with this code:
[Tumorhojd] = @xmlData.value('(BRUM-regi stret/Orig inalData20 12/Tumorho jd)[1]', 'real' )
i guess the stored procedure is the application - so how do it get it to use decimal comma?
I understand..but if i have a stored procedure with this code:
[Tumorhojd] = @xmlData.value('(BRUM-regi
i guess the stored procedure is the application - so how do it get it to use decimal comma?
Did you see my solution earlier on?
ASKER
yes but say i am programing in delphi to can convert a string '1,23' to a real number using the standard strToFloat function.
However if my code is run on a server with English settings this would give an error because it expects '1.23'
the StrToFloat function looks at the locale to determine what type of decimal character to use.
Since i am using standard tsql code i would expect the tsql functions to look at the locale and convert decimals and dates accordingly.
So my assumption is that maybe i have the locale set wrong?
However if my code is run on a server with English settings this would give an error because it expects '1.23'
the StrToFloat function looks at the locale to determine what type of decimal character to use.
Since i am using standard tsql code i would expect the tsql functions to look at the locale and convert decimals and dates accordingly.
So my assumption is that maybe i have the locale set wrong?
It is possible. I don't really know.
Open in new window