Decimal value with 5 decimal places in sql server

Asked

Viewed 441 times

1

I’m developing an application (Asp.NET MVC 5.2.3.0, EF 6.1.3 e SQL Server 2012), the database has a table with the field decimal(6, 5), when I save a value in this field -2,56478 for example in the bank he gets -2,56000. To Collation do banco é SQL_Latin1_General_CP1_CI_AI.

Is it SQL Server or EF configuration? Someone has been there and can help me?

  • you’ve tried debugging to see what’s going to the bank?

  • Already, the value goes as -2.56478. I already configured webconfig: <globalization Culture="en-BR" uiCulture="en" />.

  • Below the result of the Profiler: exec sp_executesql N'UPDATE [dbo]. [TABLE] SET [CAMPO01] = @0, [CAMPO02] = @1, [CAMPO03] = @2, [CAMPO04] = @3, [Latitude] = @4, [CAMPO05] = @5, [CAMPO06] = @6, [CAMPO07] = @7 WHERE ([ID] = @8) ', ,@8 int',@0=1001,@1=1029,@2='2016-02-17 00:00:00',@3=208,@4=-1.25,@5=-65.25,@6=2,@7=N'Qualquer coisa...',@8=2763.

  • Post the part where you do the insert and if it is proc post to proc also, what seems to be more is the guy in the field @4 decimal(18,2),@5 decimal(18,2) , see it’s only got two houses somehow this will round your value.

1 answer

0

Just for the record, the problem I mentioned above was due to the generation of the ORM being generated via Reverse Engineering (EF Powertools), unfortunately I can’t say if it was the version of the tool I’m currently using, I haven’t tested yet. More problem was solved by reverse engineering with Codefirst (Code First from database) present from Update 2 of Visual Studio 2013 and Entityframework 6.1.

Below the result of the profiler:

exec sp_executesql N'UPDATE [dbo].[TABELA]
SET [CAMPO01] = @0, [CAMPO02] = @1, [CAMPO03] = @2, [CAMPO04] = @3, **[Latitude] = @4**, [Longitude] = @5, [CAMPO05] = @6, [CAMPO06] = @7
WHERE ([ID] = @8)
',N'@0 int,@1 int,@2 datetime2(7),@3 int,**@4 decimal(6,5)**,@5 decimal(7,5),@6 tinyint,@7 varchar(max) ,@8 int',@0=1001,@1=1029,@2='2016-02-17 00:00:00',@3=208,@4=-1.25789,@5=-65.25698,@6=2,@7='Olá, Mundo...',@8=2763, agora a precision e scale são reconhecida pois no Context criado foi acrescido .HasPrecision(6, 5).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.