Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decimal/Numeric data type in SQL 2005

Status
Not open for further replies.

admdev

Programmer
May 17, 2006
56
US
Hi all,

Hope somebody can help.

I am inserting numbers with two decimal places into a decimal(10, 2) data type in SQL. However, SQL replaces the two decimal places with zeros. I tried changeing the data type to numeric(10, 2), but the same thing happens. Does anybody know why SQL does this?

Thanks in advance.
 
Admdev,

How are you doing the insert? What code are you using?

Also, are you working with DBF files or a back end database (you mentioned SQL 2005 in your question title)? If the latter, how are you sending the insert?

If you can give these details, no doubt someone will be able to help.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
MikeLewis,

Thanks for the reply.

I am using Fox Pro 9 to send the data. At first I thought it could be VFP formating it before sending it to SQL, but I supended the code to analyze the data being sent and it is the right data. For example, I am sending 1.75, when I pause the code at the insert command, the field data reads 1.75. However, when I check the record inserted, SQL shows 1.00.

Thanks.

Jose.
 
Jose,
Run SQL Profiler and see what commands you passed to SQL Server. As Mike said we could help you more if you pass the actual code you use for inserting.

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Jose,

OK, we're getting closer. From what you say, you are clearly using a remote back end. So let us know which back end it is (for example, is it SQL Server, as Borislav suggests?).

It would also help to know whether you are using SQL pass-through, a remote view, a cursoradapter, or whatever.

Also, when you say you tried changing the data type, could you confirm that you're talking about the data on the back end.

I know we are asking more questions than we are answering, but it's so much easier for having a clear understanding of the problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I figured it out.

I was using Int data type before changeing it to Decimal. I am using a store procedure to insert the record.

What happened was that I changed the data type from Int to Decimal on the table, but forgot to update the store procedure to reflect the new data type.

Thanks guys!
 
[rofl]
Give a star yourself :)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top