I am importing a CSV into a database table. I've got it loaded into its own table and I am using that table to feed 2 related tables so that the data is easier to see on a Power BI dashboard. When I attempt to copy some data from the original table I get the following error.
Msg 8152, Level 16, State 2, Procedure Update_Licence_Tables, Line 42 [Batch Start Line 2]
String or binary data would be truncated.
This is weird as the column that is causing the issue is nvarchar(255) and the destination column is also nvarchar(255). I am unsure why this error is occurring when the data types are identical.
Here is the INSERT INTO that is throwing the error. #WLD is the temp table the CSV info is saved to.
SET @active_id = (SELECT TOP(1) id FROM #WLD);
INSERT INTO WELL_LICENCE_DATA (licence_number, licence_status, unique_well_identifier, deemed_asset_amount, deemed_liability_amount_total, pvs_value_applied, active_indicator)
SELECT F1, F2, F3, CONVERT(decimal(18, 2), REPLACE(REPLACE(REPLACE(F4, '$', ''), ',', ''), ' ', '')), CONVERT(decimal(18, 2), REPLACE(REPLACE(REPLACE(F5, '$', ''), ',', ''), ' ', '')), F6, REPLACE(F7, ' ', '')
FROM #WLD
WHERE id = @active_id;
Is there a way to force ignore this warning or a known issue and fix?
Any insights are appreciated
How did you determine the column that is causing the issue? What column?
Trial and error. I removed columns to find one at a time to find it. From what I can see it is all of the columns where I am not transforming the data (F1, F2, F3, F6).
Maybe different collation causes the issue?
Hi @John Oke ,
We have not received a response from you. Did the reply could help you? If the response helped, do "Accept Answer". If it dosn't work, please let us know the progress. By doing so, it will benefit all community members who are having this similar issue. Your contribution is highly appreciated.
Sign in to comment