'String or binary data would be truncated' error message

时间:2023-01-14 15:43:01

很多人(在google)上遇到这个错误是由于数据的存储空间小于 要插入的数据。 而我遇到这个错误却是由于, column 的顺序没有排对,

我是用 insert <tableName> select * from <tablename> 和delete from <tablename> output  deleted.* into 时出错。由于select 或者delete选择的column Name 是手动排的, 和要insert 的table column顺序不一致,景观column name 都一样但还是抛出了标题的错误,更正  用的顺序是sql server management 显示的顺序, 错误排除。

delete  top (1) from s
output
            DELETED.[RatingTime]
           ,DELETED.[Comment]
           ,DELETED.[LCID]
           ,dbo.Get_LCIDNAME(DELETED.LCID) as [LCIDName]
           ,DELETED.[AssetID]
           ,a.[Title] as [Asset_Title]
           ,a.[Category]as [Asset_Category]
           ,a.[AppCode]as [Asset_Code]
           ,a.[Writer]as [Asset_Writer]
           ,a.[Editor]as [Asset_Editor]
           ,case a.LCID when null then null else dbo.get_LCIDName(a.LCID)end as [Asset_LCIDName]
           ,a.[UpToDate]as [Asset_UpToDate]
           ,a.[Provider]as [Asset_Provider]
           ,a.[WLCID]as [Asset_WLCID]
           ,a.[Byline]as [Asset_Byline]
           ,a.[TrustLevel]as [Asset_TrustLevel]
           ,a.[AppVer]as [Asset_AppVer]
    INTO OfficeOnline.dbo.tblCompliments
FROM   tblCompliments as s
    left join AssetList as a  on s.AssetID = a.AssetID