-
Decimal points in Money data type(SQL 2K)
In SQL Server 2000 the data type "Money" has 4 decimal points. I defined Money type in few of our tables. If a table is opened in design, the datatype scale is grayed out and cannot be changed. Is it possible to supress it to 2 decimals using SQL? or else, Shall I have to convert to Decimal data type in our tables?
-
The decimal places in Money datatype is fixed, you can't change it.
If you want only 2 decimal places then you have to use DECIMAL datatype.
-
you can define it as money in the table and while selecting you can use Convert
create table x (id int identity(1,1), cash money)
insert into x (cash) select 100.245
insert into x (cash) select 100.25
insert into x (cash) select 100.24
insert into x (cash) select 100.00
insert into x (cash) select 100.12
select convert(decimal(8,2),cash) from x
-
-
You do not have to convert it to decimal, you can use the style paramater of convert. For example:
declare MyMoney money
set MyMoney = 12345.123
print convert(varchar(20),MyMoney,0)
print convert(varchar(20),MyMoney,1)
print convert(varchar(20),MyMoney,2)
Result:
12345.12
12,345.12
12345.1230
-
knicholson.
FYI.
This thread is about sql server.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|