You don't 'add' numeric separators in a cast (or in a query for that =
matter.) I understood that the only separator you desired was the =
period.
You MUST change the Regional Settings on the WEB Servers to a numeric =
format that is consistent with the presentation you desire. If the =
Regional settings on the WEB Server is set to display a comma instead of =
a period as the decimal separator, that is what you will display.
Now if you cannot change the Regional settings on the Web server, you =
may try the following. (I'm going to use a 'unusual' example so that you =
will get the idea of how this technique may help you.) Run this code in =
Query Analyzer to see the difference.
DECLARE @MyTable table
( RowID int IDENTITY
, Mileage numeric(18,3)
)
SET NOCOUNT ON
INSERT INTO @MyTable VALUES ( 125.5 )
INSERT INTO @MyTable VALUES ( 69.345 )
INSERT INTO @MyTable VALUES ( 123456.789 )
INSERT INTO @MyTable VALUES ( 2000.500 )
INSERT INTO @MyTable VALUES ( 1111.1 )
INSERT INTO @MyTable VALUES ( 100.0 )
=20
--Numeric display
SELECT=20
RowID
, Mileage
FROM @MyTable
=20
-- Altered display. Replace the period with another character(s)
SELECT=20
RowID
, Mileage =3D replace( cast( Mileage as varchar(20) ), '.', '[~]' )
FROM @MyTable
Using cast() would allow you to move the decimal value into a text form =
that would not be changed by the application's use of the regional =
settings. Of course, on the application side, you need to handle the =
value as a string -not as a number. Replace() is used after (on the =
outside of ) the conversion to change the period into a different =
character.
--=20
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.=20
Most experience comes from bad judgment.=20
- Anonymous
[quoted text, click to view] "Ana_T" <nospam@yahoo.com> wrote in message =
news:u$SaJ%23lsGHA.1192@TK2MSFTNGP04.phx.gbl...
> Thank you Arnie.
> I tried CAST(numeric_field AS varchar) and I think I'm missing =
something.=20
> How do I add the numeric separators in a query?
> TIA
>=20
> "Arnie Rowland" <arnie at 1568 . moc> escribi=F3 en el mensaje=20
> news:%23YRs6llsGHA.372@TK2MSFTNGP06.phx.gbl...
>>I believe that the presentation of numeric separators is controlled by =
the=20
>>Windows regional setting.
>>
>> In the Control Panel, select Region and Language Settings, and make =
the=20
>> change there.
>>
>> However, if it concerns you about making a change that would effect =
every=20
>> operation on the computer, perhaps casting the numeric fields to =
varchar=20
>> in the query that is used to retrieve the data for display will solve =
the=20
>> problem.
>>
>> --=20
>> Arnie Rowland, Ph.D.
>> Westwood Consulting, Inc
>>
>> Most good judgment comes from experience.
>> Most experience comes from bad judgment.
>> - Anonymous
>>
>>
>> "Ana_T" <nospam@yahoo.com> wrote in message=20
>> news:O$h%23wfjsGHA.4784@TK2MSFTNGP04.phx.gbl...
>>> Hi,
>>>
>>> I use a numeric field (vs. nvarchar) to log the KM of a vehicle =
because=20
>>> I'd like the data to be displayed with the 1000 separator (123.456). =
In a=20
>>> web page, the data is displayed with decimals (123.456,00). I =
removed the=20
>>> decimal setting in the server's regional configuration with no =
avail. Is=20
>>> there a place in SQL2K where regional settings are stored?
>>>
>>> TIA
>>>
>>> Ana
>>>
>>>
>>
>>=20
>=20