.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

Which one is better: Money or Decimal?

Posted By:      Posted Date: August 24, 2010    Points: 0   Category :ASP.Net
 

Hi

I want a field to keep money value (up to 100,000,000.00). And I didn't  work with money or decimal data type.

Money data Type is 8 byte

Decimal (9, 2) is 5 byte. (Exactly msdn only say Decimal (9, 0) is 5 byte and I don't really know how byte is Decimal (9, 2))

Please tell me which one is better to work with in sql and VS.net (handling sql in VS)

Best Regards. Morteza




View Complete Post


More Related Resource Links

Sql Order by not working with decimal/money type columns

  
Error Message:- Cannot convert a char value to money. The char value has incorrect syntax. DECLARE @Order NVARCHAR(50) = 'asc', @OrderBy NVARCHAR(50) = 'Shape'SELECTtop 1 Row_Number() OVER(ORDER BY  CASE WHEN @Order IS NULL OR @Order = 'asc' THEN    CASE WHEN @OrderBy IS null THEN Shape    WHEN @OrderBy = 'Shape' THEN Shape    WHEN @OrderBy = 'Cut' THEN Cut    WHEN @OrderBy = 'Color' THEN Color    WHEN @OrderBy = 'Clarity' THEN Clarity    WHEN @OrderBy = 'Price' THEN FinalPrice    --MONEY    WHEN @OrderBy = 'Carat' THEN [Weight]   --DECIMAL   END  END ASC,  CASE WHEN @Order = 'desc' THEN    CASE WHEN @OrderBy IS null THEN Shape    WHEN @OrderBy = 'Shape' THEN Shape    WHEN @OrderBy = 'Cut' THEN Cut    WHEN @OrderBy = 'Color' THEN Color    WHEN @OrderBy = 'Clarity' THEN Clarity    WHEN @OrderBy = 'Price' THEN FinalPrice  --MONEY   WHEN @OrderBy = 'Carat' THEN [Weight]  --DECIMAL   END  

MONEY vs. DECIMAL in Business Applications

  

Money pros:

o money (operator) money yields money type

o performance is better

o sufficiently accurate for dollar monetary data and calculations like SUM, AVG and percentage

o simple

DECIMAL pros:

o variable precision & scale

o more accuracy if needed

 


Kalman Toth, SQL Server & Business Intelligence Training; SQL 2008 GRAND SLAM

decimal value validation and round off by javascript

  
The article decimal value validation and round off by javascript was added by hiral.hapani on Wednesday, June 02, 2010.

Hi All, I have createdone javascript by which you canvalidate a decimal value of any textbox for which you want. By thisjavascriptwecan bind user to enter only digits in textbox. and when he will enter any decimal value javascript will do round off it

Need RegEx for four decimal place

  
Hello All, I have total 19 digits in which i have 4 decimal place. What would be the pattern. ThanksBizTalk Beginner

How do I get Decimal.Parse to stop taking current culture into account?

  
How do I get Decimal.Parse to stop taking current culture into account?   I tried the following but I get an error saying “String was not recognized as a valid DateTime.   Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");   Decimal.Parse("5000.000,51",CultureInfo.InvariantCulture)

Bianry data to decimal value in sql

  
Hi all! can any one tell me please if we have data in one column is in binary format i.e  e.g 0111 result should be 7. How should we retrive the decimal value 7 through sql server 

Validate input has up to 2 decimal places

  
I need to validate hours put into a textbox.  I want to allow hours to be from 0-24 and allow up to 2 decimal places. so it has to accept 00.001.52.25but not 2.225 or 25I put a range validator that check that the value is from 0-24 but it doesn't check that there are 2 decimal places or less.  how do I do that?

Quick way to widen a decimal column in place?

  
Hi all, I have a table with over 400 million rows in it, and it turns out that one of the columns that was defined as decimal(14,5) needs to be widened to decimal(18,5).  The column is not used an any keys or indexes. What's the fastest way of doing that?  When I attempt to change the column definition (right-click the table in SSMS, select Design, update the column definition, then attempt to save), SSMS complains, saying Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created.... Thanks, Matthew  

Loading Decimal Number From Excel into SQL Server 2005 using SSIS Package

  
If you have an excel spreadsheet that displays a number .02 (because it is formated) but internally it is stored as .2654329 and you want to load .2654329 how can you do that in the SSIS package?  When we load the spreadsheet it is loading .02.  Is there some kind of option in the SSIS package to tell the package to load the internal number?lcerni

Quick way to widen a decimal column in place?

  
Hi all, I have a table with over 400 million rows in it, and it turns out that one of the columns that was defined as decimal(14,5) needs to be widened to decimal(18,5).  The column is not used an any keys or indexes. What's the fastest way of doing that?  When I attempt to change the column definition (right-click the table in SSMS, select Design, update the column definition, then attempt to save), SSMS complains, saying Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created.... Thanks, Matthew  

Entity Framework - Allow Dollar Signs for Decimal Types

  
Using ASP .Net 4.0,Entity Framework and EntityDataSource. I have some currency fields that are defined as Decimal. I would like to allow the user to enter a (leading) dollar sign in these (TextBox form fields). Although, when the EntityDataSource goes to save the changes to the datbase, it throws: Error while setting property 'QuotedMaterial': 'Cannot convert the value of parameter 'QuotedMaterial' to the type 'System.Decimal'.'. Does anyone know how I can "tell" the EF to allow dollar signs and convert (drop) them accordingly? I am trying to avoid creating my own Data or Business Logic layer for this particular application. I would like to stick with the EntityDataSource and other "built in" controls to minimize the C# code behind as much as possible. I guess my only alternative is to deny $ (Dollar Signs) (and commas too for that mater, it doesn't like them either). The problem is I am porting a legacy application and I would like to keep it as close to the original as possible (and they are currently allowed to enter dollar signs in this application). You see, they use copy/paste for data entry quote often on this particular form and it just so happens that the source data (they are copy/pasting from) always has a $ in it...    

Javascript numbers only, & format it to Decimal

  
Hello Experts, I need some help guys ;( I want some javascript code that make sure that end user must enter only numbers on textbox (currency,number), no characters, also typed number will be formated to be decimal number, I mean if user type (22222), javascript should format the number to be (22,222.0) javascript function should be called while end user typing on Textbox. so if he enter character, then the character should be removed automatically. I read many posts that talked about this, but most of them are using the onkeypress(event), so if the user paste the text that code will not work. Please help me guys, I need this urgent

how to format money in an sql statement

  
  Hello All, I am trying to format money to be inserted  to an sql statement.  I currently have this str = str + "'" + a.Trim + "', '" + b.Trim + "', '" + System.DateTime.Now + "', money, " when i hard code money as 2.00, for example: str = str + "'" + a.Trim + "', '" + b.Trim + "', '" + System.DateTime.Now + "', 2.00, " it works fine, but when i am using a variable like  dim money as double money = dr("amount").ToString()    as with the 1st example i get the error message: Input string was not in a correct format. please help me.   -Kagome  

Rounding problem for money output parameter from stored proc

  
I have a GridView sourced by a SQL Server stored procedure with several databound fields, including a money column for item values. My stored proc returns the data through a SELECT and everything looks good. The stored proc also has a single output parameter that sums the total value of the displayed data, and this value is displayed in a label above the GridView. The output parameter (defined as money on the SQL Server side) is passed back to the app in good shape, but is rounded when displayed in the DataSource_Selected event handler. So a total of $30,155.22 in SQL Server shows up as $30155 on my aspx.In debugging, I have confirmed that the value leaving SQL Server is correct (30155.2200), and I can see that the value coming IN to the ASP-side event handler is already rounded. What do I need to do here to coerce/force it to show as money/currency?Relevant snippets:Stored Proc:... @onHandValue money OUT...  CREATE TABLE #tempValueOnHand(... valueOnHand money )... set @onHandValue = (select round(sum(valueOnHand), 2) from #tempValueOnHand) set @onHandValue = (select sum(valueOnHand) from #tempValueOnHand)And again, the output parameter @onHandValue is coming back, just already rounded.On the ASP side:    Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSourc

Unpack Decimal transformation in SSIS 2008?

  
Hi, In order to convert the packed fields, Microsoft has released Unpack Decimal transformation but it supports only SSIS 2005 version. I don't see a version that can support the SSIS 2008. Please let me know, as to how to handle these packed feilds using SSIS 2008. Regards, Tushar.

SQL Server Money datatype pushed to SqlDataSource

  

I have a table in my SQL Server db with fields of money datatype.  It seems as though SQL Server likes to have 4 decimal places for the money datatype, but is there any way in the settings of this table or that money field to change this to 2?  I know how to programmitically trim the last two zeros, just wondering if I can manually set something so I don't have to do this every time I retrieve the money datatypes from the database table.

Thanks in advance! :)


DECIMAL with dynamic parameters

  

I am trying to create a function to do the following formatting:

RIGHT(CONVERT(DECIMAL(@precision,@decimal),@number),@width)

Unfortunately DECIMAL is not a function and therefore does not take parameters it seems.

CREATE FUNCTION DigitFormat(@number as TEXT, @precision as INTEGER, @decimal as INTEGER, @width as INTEGER)
RETURNS VARCHAR(100)
BEGIN
declare @Return VARCHAR(100)
SET @Return = RIGHT(CONVERT(DECIMAL(@precision,@decimal),@number),@width)
return @Return
END
Is there a way to solve this? I tried using EXEC but got no where...

 

 


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend