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 8443189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:04:24+00:00 2026-06-10T09:04:24+00:00

I have a datatable with values consists of more than 12 decimal places (e.g.

  • 0

I have a datatable with values consists of more than 12 decimal places (e.g. 451234.123456789012) that I’m fetching from an Excel sheet. I’m inserting the values from datatable to SQL table using user-defined table.

In my stored procedure I have a statement like,

insert into tblMytable(fld1, fld2..)
Select fld1, fld2,.. from @MyUDT

Issues:

  1. Suppose all the Excel cell type is ‘General’ I’m getting the full precision in the data table but when I’m inserting this to SQL table I’m losing all except 2 precisions.

  2. Suppose all the Excel cell type is ‘Text’ I’m getting only 12 digits for the entire value including Non decimal. Decimal part. e.g. For 451234.123456789012, I’m getting 451234.12345 in my C# datatable. And the same I’m getting after inserting to SQL table.

In my UDT the fields are defined as varchar(20), I checked with varchar(45) but no use.

  • 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-06-10T09:04:26+00:00Added an answer on June 10, 2026 at 9:04 am

    I have handled the issue using,

    Since I’m getting the full precision while reading the excel type as general to the C# datatable, I created a datatable clone by changing the column type alone as string, so that I’ll get the values all string type as well as with full precision, then i’m passing the datatable to SQL 2008 table without losing the precision, now its working fine.

    Code:

    dt= ds.Tables[0].Clone();
    for (ICol = 0; ICol < ds.Tables[0].Columns.Count; ICol++)
        dt.Columns[ICol].DataType = typeof(string);
        foreach (DataRow row in ds.Tables[0].Rows) 
        {
            dt.ImportRow(row); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataTable populated with values from a database. I have another datatable
I have a datatable that stores location values as such: CTY_CD, STATE_CD, COUNTRY_CD and
I have a datatable. I am populating some values into that. e.g. DataTable dt
I have a DataTable that contains a multi-select choice field (string). Values in the
I have a method that calculates intraclass correlation based off a datatable of values.
I have this datatable, which will display the values from the database. private void
I have a Datatable that contains a column called Tags, Tags can have values
I have this datatable that loadied from the datatabase, here is : <p:dataTable id=cars
I have a Datatable in my C# program that I would like to INSERT
I have datatable and I am displaying those values in the datagridview with the

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.