-1

我有一个查询,它有如下一行:

  CAST(REPLACE(CAST(ORDER_NOTES.BLOBDATA AS VARCHAR(250)), CHAR(13)+CHAR(10), '') AS NVARCHAR(250)) AS ORDER_NOTES

此行在SELECT语句中运行良好,但是当使用INSERT INTO带有此查询的 an 时,我得到:

Msg 8115, Level 16, State 6, Line 1
Arithmetic overflow error converting nvarchar to data type numeric.
The statement has been terminated.

列的目标数据类型是NVARCHAR(250).

有什么想法可以尝试解决此问题吗?

下面的完整查询(我确定它是我选择中的最后一个字段,好像我替换将为 NULL,我没有收到错误)

INSERT INTO T_SALES_ORDERS
SELECT
  R_SORD.SORDIDX,
  R_SORDD.SORDDIDX,
  R_SOZD.SOZDIDX,
  T_PRODUCTS.SKUIDX,
  CAST(R_SORD.NUM AS NVARCHAR(250)) AS LEGACY_NUMBER,
  CAST(R_SORD.NUM AS NVARCHAR(250)) AS EXTERNAL_REFERENCE_NUMBER,
  CAST(R_SORD.CORDER AS NVARCHAR(250)) AS CUSTOMER_ORDER_NUMBER,
  CAST(T_CUST.CUSTOMER_CODE AS NVARCHAR(250)) AS CUSTOMER_CODE,
  CAST(BILLTO.CUSTOMER_CODE AS NVARCHAR(250)) AS BILLTO_CODE,
  CAST(DC.CUSTOMER_CODE AS NVARCHAR(250)) AS DC_CODE,
  CAST(CONVERT(CHAR(10), R_SORD.ODAT, 103) AS NVARCHAR(250)) AS ORDER_DATE,
  CAST(CONVERT(CHAR(10), R_SORD.DUEF, 103) AS NVARCHAR(250)) AS DUE_DATE,
  CAST(CONVERT(CHAR(10), R_SORD.CAND, 103) AS NVARCHAR(250)) AS CANCEL_DATE,
  CAST(M_SO_TYPE.AP21_CODE AS NVARCHAR(250)) AS SO_TYPE,
  CAST(NULL AS NVARCHAR(250)) AS BARCODE,
  CAST(T_PRODUCTS.PRODUCT_CODE AS NVARCHAR(250)) AS STYLE_CODE,
  CAST(T_PRODUCTS.COLOUR_CODE AS NVARCHAR(250)) AS COLOUR_CODE,
  CAST(T_PRODUCTS.SIZE_CODE AS NVARCHAR(250)) AS SIZE_CODE,
  CAST(R_SOZD.PRICE AS NVARCHAR(250)) AS PRICE,
  CAST(CAST(R_SOZD.QTY AS INT) AS NVARCHAR(250)) AS QTY,
  CAST('19' AS NVARCHAR(250)) AS REF1,
  CAST(NULL AS NVARCHAR(250)) AS LEGACY_REF1,
  CAST(NULL AS NVARCHAR(250)) AS REF2,
  CAST(NULL AS NVARCHAR(250)) AS LEGACY_REF2,
  CAST('Standard' AS NVARCHAR(250)) AS REF3,
  CAST(NULL AS NVARCHAR(250)) AS LEGACY_REF3,
  CAST(M_PROMOTION.AP21_CODE AS NVARCHAR(250)) AS REF4,
  CAST(PROMOTION.CODE AS NVARCHAR(250)) AS LEGACY_REF4,
  CAST(M_ORDER_SEASON.AP21_CODE AS NVARCHAR(250)) AS REF5,
  CAST(ORDER_SEASON.CODE AS NVARCHAR(250)) AS LEGACY_REF5,
  CAST(NULL AS NVARCHAR(250)) AS REF6,
  CAST(NULL AS NVARCHAR(250)) AS LEGACY_REF6,
  CAST(NULL AS NVARCHAR(250)) AS REF7,
  CAST(NULL AS NVARCHAR(250)) AS LEGACY_REF7,
  CAST(NULL AS NVARCHAR(250)) AS REF8,
  CAST(NULL AS NVARCHAR(250)) AS LEGACY_REF8,
  CAST(NULL AS NVARCHAR(250)) AS REF9,
  CAST(NULL AS NVARCHAR(250)) AS LEGACY_REF9,
  CAST(NULL AS NVARCHAR(250)) AS REF10,
  CAST(NULL AS NVARCHAR(250)) AS LEGACY_REF10,
  CAST(REPLACE(CAST(R_SORD.DELINS AS VARCHAR(250)), CHAR(13)+CHAR(10), ' ') AS NVARCHAR(250)) AS DELIVERY_INSTRUCTIONS,
  CAST(REPLACE(CAST(ORDER_NOTES.BLOBDATA AS VARCHAR(250)), CHAR(13)+CHAR(10), '') AS NVARCHAR(250)) AS ORDER_NOTES
FROM
  R_SORD
INNER JOIN
  R_SORDD ON
  R_SORDD.SORDIDX = R_SORD.SORDIDX
  AND R_SORDD.ACTIVE = 1
INNER JOIN
  R_SOZD ON
  R_SOZD.SORDDIDX = R_SORDD.SORDDIDX
  AND R_SOZD.ACTIVE = 1
LEFT OUTER JOIN
  R_REFCODE SO_TYPE ON
  SO_TYPE.RCIDX = R_SORD.TYPE
LEFT OUTER JOIN
  M_SO_TYPE ON
  M_SO_TYPE.LEGACY_CODE = SO_TYPE.CODE
LEFT OUTER JOIN
  T_CUST ON
  T_CUST.CUSTIDX = R_SORD.CUSTIDX
LEFT OUTER JOIN
  T_CUST BILLTO ON
  BILLTO.CUSTIDX = R_SORD.BILLTO
LEFT OUTER JOIN
  T_CUST DC ON
  DC.CUSTIDX = R_SORD.DC
LEFT OUTER JOIN
  T_PRODUCTS ON
  T_PRODUCTS.SKUIDX = R_SOZD.SKUIDX
LEFT OUTER JOIN
  R_BLOBTBL ORDER_NOTES ON
  ORDER_NOTES.BLOBIDX = R_SORD.NOTESIDX
LEFT OUTER JOIN
  R_REFCODE PROMOTION ON
  PROMOTION.RCIDX = R_SORD.REF4
LEFT OUTER JOIN
  M_PROMOTION ON
  M_PROMOTION.LEGACY_CODE = PROMOTION.CODE
LEFT OUTER JOIN
  R_REFCODE ORDER_SEASON ON
  ORDER_SEASON.RCIDX = R_SORD.REF1
LEFT OUTER JOIN
  M_ORDER_SEASON ON
  M_ORDER_SEASON.LEGACY_CODE = ORDER_SEASON.CODE
WHERE
  R_SORD.TYP = 1
  AND R_SORD.ACTIVE = 1
  AND R_SOZD.QTY > 0
4

1 回答 1

1

将 annvarchar插入numeric字段时遇到算术溢出错误 -nvarchar转换为的数字对于该字段来说太大numeric

于 2013-10-09T03:19:36.330 回答