欢迎来到星创云技术支持社区,马上注册,享更多服务。 公众号:bjxcyun
您需要 登录 才可以下载或查看,没有账号?立即注册
x
BS3000+系统中,有个别几张单据验收的时候提示:key violation 违反了primary key约束pk_spkcb不能在对象spkcb中插入重复键,处理方法。
单据明细里检查一下CKDM,SPDM,GG1DM,GG2DM中是否有空格之类的,这个约束和这四个字段有关。可用SQL语句进行更新。可用RTRIM(去除右空格)和LTRIM(去除左空格)来进行更新。
部分脚本文件
delete from savedetail
declare @TableName sysname
,@ExecStr nvarchar(4000)
declare GetTableName cursor for select distinct ob.name from syscolumns as co, sysobjects as ob where co.id = ob.id and co.name = 'SPDM'
and ob.xtype = 'U'
open GetTableName
fetch next from GetTableName into @TableName
while @@fetch_status = 0
begin
set @ExecStr = 'update ' + @TableName + ' set SPDM = LTrim(RTrim(SPDM))'
execute sp_executesql @ExecStr
fetch next from GetTableName into @TableName
end
close GetTableName
deallocate GetTableName
GO
declare @TableName sysname
,@ExecStr nvarchar(4000)
declare GetTableName cursor for select distinct ob.name from syscolumns as co, sysobjects as ob where co.id = ob.id and co.name = 'GG1DM'
and ob.xtype = 'U'
open GetTableName
fetch next from GetTableName into @TableName
while @@fetch_status = 0
begin
set @ExecStr = 'update ' + @TableName + ' set GG1DM = LTrim(RTrim(GG1DM))'
execute sp_executesql @ExecStr
fetch next from GetTableName into @TableName
end
close GetTableName
deallocate GetTableName
GO
declare @TableName sysname
,@ExecStr nvarchar(4000)
declare GetTableName cursor for select distinct ob.name from syscolumns as co, sysobjects as ob where co.id = ob.id and co.name = 'GG2DM'
and ob.xtype = 'U'
open GetTableName
fetch next from GetTableName into @TableName
while @@fetch_status = 0
begin
set @ExecStr = 'update ' + @TableName + ' set GG2DM = LTrim(RTrim(GG2DM))'
execute sp_executesql @ExecStr
fetch next from GetTableName into @TableName
end
close GetTableName
deallocate GetTableName
GO
update GUIGE1
set GGDM=LTrim(RTrim(GGDM))
update GUIGE2
set GGDM=LTrim(RTrim(GGDM))
|
|
tomkey