如何删除表中的重复记录 表中有image 数据类型

kfigri 2003-10-24 10:35:51
select distinct * into #tmp from info
drop table info
select * into info from #tmp
drop table #tmp
我用这玩意不行..提示不能以 DISTINCT 方式选择 text、ntext 或 image 数据类型。

各位大虾帮帮我..
...全文
66 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
kfigri 2003-10-28
  • 打赏
  • 举报
回复
up
kfigri 2003-10-27
  • 打赏
  • 举报
回复
晕了..还是不懂啊..我现在要删除info表中的重复记录..里有个content的属性是text的.

帮帮偶啊..写个语句出来..谢谢!!!!!
sdhdy 2003-10-24
  • 打赏
  • 举报
回复
大力的方法应该可以!
aierong 2003-10-24
  • 打赏
  • 举报
回复
蚂蚁的:去除重复值
如果有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-10-24
  • 打赏
  • 举报
回复
alter table 表 add newfield int identity(1,1)

delete 表
where newfield not in(
select min(newfield) from 表 group by 除newfield外的所有字段和image列
)

alter table 表 drop column newfield
pengdali 2003-10-24
  • 打赏
  • 举报
回复
alter table 表 add newfield int identity(1,1)

delete 表
where newfield not in(
select min(newfield) from 表 group by 除newfield外的所有字段
)

alter table 表 drop column newfield
lvltt 2003-10-24
  • 打赏
  • 举报
回复
使用 UPDATETEXT 在适当的位置更改 text、ntext 或 image 列的一部分。

删除现有数据:指定一个非空 insert_offset 值、非零 delete_length 值。不指定要插入的新数据。
hjb111 2003-10-24
  • 打赏
  • 举报
回复
你应创建一个ID号,通过ID号删除,不可能通用IMAGE来查询重复记录!
friendliu 2003-10-24
  • 打赏
  • 举报
回复
使用 text、ntext 和 image 函数
有两个 text、ntext 和 image 函数专门用于对 text、ntext 和 image 数据所进行的操作:

TEXTPTR 返回 binary(16) 对象,该对象包含指向 text、ntext 或 image 实例的指针。指针一直有效,直到删除该行。


TEXTVALID 函数用来检查指定的文本指针是否有效。
文本指针被传递到用于操作 text、ntext 和 image 数据的 READTEXT、UPDATETEXT、WRITETEXT、PATINDEX、DATALENGTH 和 SET TEXTSIZE Transact-SQL 语句。

在 Transact-SQL 语句中,总是使用数据的指针或地址来引用 text、ntext 和 image 数据。

下面的示例使用 TEXTPTR 函数来查找与 pubs 数据库的 pub_info 表中 pub_id 0736 相关联的 text 列 (pr_info)。下例首先声明一个局部变量 @val。然后将文本指针(长二进制字符串)置于 @val 中,并将其作为参数提供给 READTEXT 语句,该语句将返回从第五个字节(偏移量为 4)开始的 10 个字节。

USE pubs
DECLARE @val varbinary(16)
SELECT @val = textptr(pr_info) FROM pub_info
WHERE pub_id = '0736'
READTEXT pub_info.pr_info @val 4 4

下面是结果集:

(1 row(s) affected)

pr_info
----------------------------------------
yet

支持使用 CAST 函数进行从 text 到 varchar、从 ntext 到 nvarchar 和从 image 到 varbinary 或 binary 的显式转换,但 text 或 image 数据将截断为 8,000 个字节,ntext 数据将截断为 4,000 个字符(8,000 个字节)。从 text、ntext 或 image 到其它数据类型的转换(无论是显式的还是隐性的)都不支持。但是,可以对 text、ntext 或 image 数据进行间接转换,例如:

CAST( CAST( text_column_name AS VARCHAR(10) ) AS INT )。

34,874

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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