User Defined Table Type

  • Hello All,
    I have this issue that I cannot seem to figure out.

    I have 2 UDTT, based off of this site https://www.aspsnippets.com/Articles/SqlBulkCopy--Bulk-Insert-records-and-Update-existing-rows-if-record-exists-using-C-and-VBNet.aspx
    So I am passing to my stored procedure my data table.
    In one of the UDTT's I am passing in over 300K of records and it updates and inserts very quickly no issues at all.
    My other UDTT will work if I only pass in a limited amount of record, but if I try and pass in the full amount 90K count of records it fails with error:

     Arithmetic overflow error converting expression to data type nvarchar.
    The data for table-valued parameter "@tblAttorneys" doesn't conform to the table type of the parameter.
    The statement has been terminated.

    SO in my first UDTT it runs just fine with over 300K of records,
    The second one runs only on a limited amount of records, and fails on 90K of records.
    Can anyone help me out and tell me what is happening.

    FYI, the UDTT I am having issues with both the UDTT and the physical table allow nulls in all fields, so even if I were to pass in nulls in my update and insert statements I still get the same error.
    Thanks,
    KSS

  • kss113 - Friday, February 23, 2018 2:14 PM

    SO in my first UDTT it runs just fine with over 300K of records,
    The second one runs only on a limited amount of records, and fails on 90K of records.

    Can you run all of the records if you only run it with limited number of rows or does it always fail when it gets to the 90K point? Is this problem only for one set of data that you are trying to insert where you have to limit it?

    Error seems to be that in your code you are converting / casting a value to nvarchar datatype which the size of your nvarchar field seems to small for. Check the data that you are pulling and test the length and check that your field in your UDTT is large enough to hold your values.

  • In sql server and in Azure the field that was causing the issue was a nvarchar(255), but the field coming back from salesforce was a numeric(10,0), so in my UDTT I change the field from nvarchar to numeric and that resolved my issue.
    Thanks,.
    KSS.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply