I get the following error when running this insert query. Despite several hours searching for a solution, I am stuck. Can you advise the solution, please.
error = "Msg 8169, Level 16, State 2, Line 31
Conversion failed when converting from a character string to uniqueidentifier."
Query
INSERT IN_UnitOfMeasure (RecID,IN_Main_InventoryID,Name, Inner_IN_UnitOfMeasure_RecID, QuantityInnersPerUnitOfMeasure, IsSell, IsPurchase,PartNo, Barcode, IsEnabled, ItemNo, LastSavedDateTime)
SELECT
CAST(NEWID() AS UNIQUEIDENTIFIER),
IN_Main.InventoryID,
'Bag',
'',
AA_IN_OrderUnits.OrderUnits,
1,
1,
LTRIM((RTRIM(IN_Main.PartNo)) +'B'),
'',
1,
1,
GETDATE()
FROM IN_Main, AA_IN_OrderUnits
WHERE IN_Main.InventoryID = AA_IN_OrderUnits.InventoryID
Table AA_IN_OrderUnits is a custom table. Also tried wwithout the CAST function and received the same error.