How do I save the value to decimals before the point in sql server?

Asked

Viewed 381 times

2

I have a field in the bank with this format

TESTE   numeric(8, 3)     

I want to record this form.

UPDATE TB_PLANO_CONTAS SET TESTE = 001.000 WHERE  IDPLANOCONTAS = 63

The result is getting like this: 1,000

UPDATE TB_PLANO_CONTAS SET TESTE = 101.000 WHERE  IDPLANOCONTAS = 64

The result is getting like this: 101,000

  • sql ignores the zeros on the left.

  • 1

    Why do you need to do this? Any number field will drop the zeroes on the left. Anyway, it seems to me that the amount you need to record is not a number, but a kind of accounting account. If so, then you should change the field to String, because that’s what makes sense to your problem.

  • All ignore zeros to the left of a value.

1 answer

1

This problem is occurring because the field created in SQL is numerical. Thus, the left zeros are ignored. Even if you loop to insert the zeros, you won’t be able to.

One way to do this is to change the field from numeric to character, but then you have to see your field type need.

Browser other questions tagged

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