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

  • SEARCH
  • Home
  • 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 9010193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:23:36+00:00 2026-06-16T02:23:36+00:00

I have two tables and I would like to insert from one into the

  • 0

I have two tables and I would like to insert from one into the other. In my staging (source) table every column is defined as nvarchar(300) and this restriction cannot change.

In my destination table, the columns are of all different types. If I want to, for example, select from the source table (data type nvarchar(300)) and insert that column into a data type of decimal(28, 16).

When this happens I get the following error:

Error converting data type nvarchar to numeric.

Even when I use a cast I get the error.

INSERT INTO Destination (
    Weighting
)
VALUES (
    CAST(src.Weighting AS decimal(28, 16))
)

Could null values be affecting this at all? Is there anything else to consider?

  • 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-16T02:23:38+00:00Added an answer on June 16, 2026 at 2:23 am

    If all data in your staging table column can be implicitly converted to the target data type then you do not have to set up an explicit cast.

    But if any one value cannot be converted implicitly (i.e. one cell contains a non-numeric or ill-formatted string value that is supposed to end up in a decimal type column) then the entire transaction will fail.

    You can migrate the risk of a failing transaction by setting up the insert like this:

    INSERT
      LiveTable (
        VarcharCol,
        DecimalCol,
        NonNullableCol
      )
    SELECT
      NvarcharCol1,
      CASE ISNUMERIC(nvarcharCol2) = 0 THEN NvarcharColl2 END,
      ISNULL(NvarcharCol3, '')
    FROM
      StagingTable
    

    But clearly that means the risk of losing potentially relevant data or numeric precision.

    You can read which data types are implicitly convertible between each other on the MSDN (scroll down to the matrix). For all other conversions you’ll have to use CAST or CONVERT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables with identical structure except for one column... Table 2 has
I have two tables user and log. I would like to join the user
I have two tables, name and address. I would like to list the last_name
I have two tables: Companies: (id, name) Workers: (id, name, country) I would like
I have two different tables, lead and click. I would like to query MySQL
I was thinking that I would have two tables for mysql. One for storing
I have two tables one table tbl_OrderLine with order ID and one tbl_Student with
I have two DB real and backDB. I would like to copy everything from
I have two tables with a many-to-one relationship. (Oracle) **Table: PARENT** Field: A (PK)
I have two tables linked by a foreign key. Example: CREATE TABLE one (id

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.