SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


User Defined Table Type


User Defined Table Type

Author
Message
kss113
kss113
SSC-Addicted
SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)

Group: General Forum Members
Points: 426 Visits: 78
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
reinhardcilliers
reinhardcilliers
Right there with Babe
Right there with Babe (777 reputation)Right there with Babe (777 reputation)Right there with Babe (777 reputation)Right there with Babe (777 reputation)Right there with Babe (777 reputation)Right there with Babe (777 reputation)Right there with Babe (777 reputation)Right there with Babe (777 reputation)

Group: General Forum Members
Points: 777 Visits: 5607
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.

kss113
kss113
SSC-Addicted
SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)SSC-Addicted (426 reputation)

Group: General Forum Members
Points: 426 Visits: 78
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search