我的数据库出现的问题

yhs000 2003-11-10 11:38:20
朋友:你好!
我在删除数据库表中部分与全部分记录时出现了这种提示:
[Microsoft][ODBC SQL Server driver][SQL Server]不能在具有唯一索引'uc1MSmerge tombstone'的对象'
Smerge_tombstone'中插入重复键的行。[Microsoft][ODBC SQL Server Driver][SQL Server]语句已终止。
但这种情况下,我从程序界面可以新录记录与删除新录记录,在处理原来已经存在的记录时,提示“删除失败,数据提交不功。”
我的数库有发布与订阅存在,如果除去发布与订阅,就能删除原来的记录,但现在我不想删除发布与订阅,有什么办法解决这个问题,是什么原因引起的?
 烦速回复,谢谢!
...全文
53 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengdali 2003-11-10
  • 打赏
  • 举报
回复
先选中你那个发布的数据库-->工具-->复制-->禁用发布-->分离数据库
再做即可。
txlicenhe 2003-11-10
  • 打赏
  • 举报
回复
资料中有重复值。



蚂蚁的:去除重复值
如果有ID字段,就是具有唯一性的字段

delect table where id not in (

select max(id) from table group by col1,col2,col3...
)
group by 子句后跟的字段就是你用来判断重复的条件,如只有col1,那么只要col1字段内容相同即表示记录相同。



2,如果是判断所有字段也可以这样
select * into #aa from table group by id1,id2,....
delete table
insert into table
select * from #aa



3,没有ID的情况

select identity(int,1,1) as id,* into #temp from tabel
delect # where id not in (
select max(id) from # group by col1,col2,col3...)
delect table
inset into table(...)
select ..... from #temp


col1+','+col2+','...col5 联合主键


select * from table where col1+','+col2+','...col5 in (

select max(col1+','+col2+','...col5) from table
where having count(*)>1
group by col1,col2,col3,col4
)
group by 子句后跟的字段就是你用来判断重复的条件,如只有col1,那么只要col1字段内容相同即表示记录相同。

2,
select identity(int,1,1) as id,* into #temp from tabel
select * from #temp where id in (
select max(id) from #emp where having count(*)>1 group by col1,col2,col3...)


pengdali 2003-11-10
  • 打赏
  • 举报
回复
delect fpkjk where id not in (select max(id) from fpkjk group by nsh, dm1, dm2, gyl,swjgbh)
yhs000 2003-11-10
  • 打赏
  • 举报
回复
txlicenhe(马可)朋友:
   我用你的办法 delect fpkjk where id not in (

select max(id) from table group by nsh, dm1, dm2, gyl, swjgbh
)
运行后出现这样的提示:[Microsoft][ODBC SQL Server Driver]syntax error or access violation.
我的数据库表(FPDJK)结构是这样的,字段为nsh,jm1,dm2,swjgbh,gyl,flag,xjqx,yjdm,uptime,rowguid.
其中前四个字段设为主键。我不知道是什么原因?请帮助我,谢谢

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧