Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7612969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:03:07+00:00 2026-05-31T02:03:07+00:00

I need to insert numbers with decimals into a SQL Server 2008 database. It

  • 0

I need to insert numbers with decimals into a SQL Server 2008 database. It seems like decimal() is the correct data type to use, however, I’m having trouble understanding it exactly.

I found this script (scroll down for decimal):

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=95322

Which allows me to test different decimal settings against numbers, and there’s some I don’t understand why they pass or fail. The way I understand it, when using decimal(precision, scale), precision is the number of digits to the left of the decimal and scale is the number of digits to the right of the decimal. Using this function, I don’t understand why some are passing and why some are failing.

SELECT dbo.udfIsValidDECIMAL('2511.1', 6, 3)    

I have 4 digits on the left and 1 on the right, yet this fails.

SELECT dbo.udfIsValidDECIMAL('10.123456789123456789', 18, 17)    
SELECT dbo.udfIsValidDECIMAL('10.123456789123456789', 18, 16)

The first one fails, the second one passes. There are 18 digits after the decimal point, so it seems like both should fail (or pass and SQL truncates the number).

Maybe I have a fundamental misunderstanding in how decimal() is supposed to work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:03:08+00:00Added an answer on May 31, 2026 at 2:03 am

    Precision is the number of digits that can be stored total.

    So the number to the left of the decimal will be precision – scale.

    For example, your first example will fail because you are only allowing for three places to the left of the decimal:

    SELECT dbo.udfIsValidDECIMAL('2511.1',6,3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to insert data from table1 into table2. However, I would like to
I need to be able to insert numbers like 098532 into my table. This
I need to summarize numbers like CREATE TABLE #t(num int); INSERT #t SELECT 10001
Hi need insert data in table if the record is not already exits Ex:
Need to insert selected text on the page into textarea. There must be some
I need to insert records into a table that has no primary key using
I need to insert an HTML string into the <head> tag of the current
I need to insert about 1.8 million rows from a CSV file into a
I need to insert/update data by using link or image I need a code
I'm trying to insert variables from an SQL result into a HTML form in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.