见鬼了,高手请来,分不够可另开贴给。

huolx 2004-05-07 05:45:28
起因:我想读取列的描述。

根据 zjcxc(邹建)的回答,用

SELECT 字段名=article.name,字段说明=isnull(g.[value],'')
FROM syscolumns article
left join sysproperties g on article.id=g.id and article.colid=g.smallid
where article.id=object_id('article')
and article.name in('title','sourcetype')

article是表名,title,sourcetype是字段名,得到的结果是


sourcetype True
sourcetype 2
sourcetype 1033
sourcetype False
sourcetype 0
sourcetype -1
sourcetype False
sourcetype ய䡮₊輚輽愆
sourcetype 文章来源类别
sourcetype 109
sourcetype 1
sourcetype 3
sourcetype sourcetype
sourcetype 2
sourcetype False
sourcetype 50
sourcetype sourcetype
sourcetype article
sourcetype 10
sourcetype True
title False
title 2
title 1033
title False
title 0
title -1
title False
title ⛀㤢䘜宵황䏹熉
title 标题,题目
title 109
title 1
title 3
title title
title 1
title False
title 50
title title
title article
title 10
title True

正常的结果应是

sourcetype 文章来源类别
title 标题,题目

后来又试了几次,发现在其他数据库上均可正常运作,唯独在我开始测试的这个数据库上出现异常,这个数据库是我现在网站所用数据库,平时运作很正常。
仔细对比了一下区别,我发现系统表sysproperties似乎有些不正常,有2810条数据,别的数据库一般才几十条。

请高手出手!谢谢
...全文
68 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
huolx 2004-05-09
  • 打赏
  • 举报
回复
以下是zjcxc(邹建)的回答
查询分析器中执行下述语句
use 你的库名
go


SP_CONFIGURE 'ALLOW UPDATES',1 RECONFIGURE WITH OVERRIDE
GO

delete a
from sysproperties a
join sysobjects b on a.id=b.id
where b.xtype='U' and b.status>=0
and a.name<>'MS_Description'
go

SP_CONFIGURE 'ALLOW UPDATES',0 RECONFIGURE WITH OVERRIDE
GO

我测试过,完全正常了,非常感谢。还有 8992026(8992026),也非常感谢
internetcsdn 2004-05-08
  • 打赏
  • 举报
回复
真的见鬼了.
huolx 2004-05-08
  • 打赏
  • 举报
回复
请教:sysproperties是否只是用来存放描述信息?我有些担心用delete sysproperties
where name<>'MS_Description'
会将其它有用信息也删除。
huolx 2004-05-08
  • 打赏
  • 举报
回复
就是弄成和正常的一样就行了,当然是所有的表都处理。需要把表都发给您吗?
8992026 2004-05-08
  • 打赏
  • 举报
回复
delete sysproperties
where name<>'MS_Description'
zjcxc 元老 2004-05-08
  • 打赏
  • 举报
回复
你要处理那些内容还没告诉你呢.
tsh1979 2004-05-08
  • 打赏
  • 举报
回复
up
huolx 2004-05-08
  • 打赏
  • 举报
回复
上面那个查询的结果是
4 AllowZeroLength
4 Attributes
4 CollatingOrder
4 ColumnHidden
4 ColumnOrder
4 ColumnWidth
4 DataUpdatable
4 GUID
4 MS_Description
4 MS_DisplayControl
4 MS_IMEMode
4 MS_IMESentMode
4 Name
4 OrdinalPosition
4 Required
4 Size
4 SourceField
4 SourceTable
4 Type
4 UnicodeCompression
4 AllowZeroLength
4 Attributes
4 CollatingOrder
4 ColumnHidden
4 ColumnOrder
4 ColumnWidth
4 DataUpdatable
4 GUID
4 MS_Description
4 MS_DisplayControl
4 MS_IMEMode
4 MS_IMESentMode
4 Name
4 OrdinalPosition
4 Required
4 Size
4 SourceField
4 SourceTable
4 Type
4 UnicodeCompression
huolx 2004-05-08
  • 打赏
  • 举报
回复
发送者 zjcxc
发送时间 2004-5-8 10:44:08 删除 回复
内容 只改这个表的这两个字段,还是所有的表都改?
将这个结果列出来吧
SELECT g.type,g.name
FROM syscolumns article
left join sysproperties g on article.id=g.id and article.colid=g.smallid
where article.id=object_id('article')
and article.name in('title','sourcetype')

----------------------------------------------------------------
原贴内容:
非常感谢您。
不过我想并不是我原数据库有问题,因为我用access重建了一个表,然后升迁到SQL,得到的结果是一样的。
是不是您是用的数据导入导出?那样得到的结果是正确的。
我是用的access菜单-》工具-》数据库实用工具-》升迁向导来做的,一切都使用默认值。我现在用得是access2003,有问题的这个库升迁的时候用的access2002.应该不是access版本的问题。

您给出的3个查询,第一个是正常的。那您是否能给出一个删除多余信息的sql脚本?
最好能严谨一些,因为这个数据库现在正在应用中。谢谢
----------------------------------------------------------------
原贴内容:
我初步怀疑是升迁将字段的扩展属性搬到里面去了,导致有多余信息.
你看看我在帖子上提供的三个查询的结果是什么?
huolx 2004-05-08
  • 打赏
  • 举报
回复
抱歉,各位,昨晚很早就下了。
感谢邹建兄,您给出的3个查询
第一个可以得到正常结果:

sourcetype 文章来源类别
title 标题,题目

第二个为空:
第三个为:
sourcetype True 1125579048 3 4 AllowZeroLength
sourcetype 2 1125579048 3 4 Attributes
sourcetype 1033 1125579048 3 4 CollatingOrder
sourcetype False 1125579048 3 4 ColumnHidden
sourcetype 0 1125579048 3 4 ColumnOrder
sourcetype -1 1125579048 3 4 ColumnWidth
sourcetype False 1125579048 3 4 DataUpdatable
sourcetype ய䡮₊輚輽愆 1125579048 3 4 GUID
sourcetype 文章来源类别 1125579048 3 4 MS_Description
sourcetype 109 1125579048 3 4 MS_DisplayControl
sourcetype 1 1125579048 3 4 MS_IMEMode
sourcetype 3 1125579048 3 4 MS_IMESentMode
sourcetype sourcetype 1125579048 3 4 Name
sourcetype 2 1125579048 3 4 OrdinalPosition
sourcetype False 1125579048 3 4 Required
sourcetype 50 1125579048 3 4 Size
sourcetype sourcetype 1125579048 3 4 SourceField
sourcetype article 1125579048 3 4 SourceTable
sourcetype 10 1125579048 3 4 Type
sourcetype True 1125579048 3 4 UnicodeCompression
title False 1125579048 2 4 AllowZeroLength
title 2 1125579048 2 4 Attributes
title 1033 1125579048 2 4 CollatingOrder
title False 1125579048 2 4 ColumnHidden
title 0 1125579048 2 4 ColumnOrder
title -1 1125579048 2 4 ColumnWidth
title False 1125579048 2 4 DataUpdatable
title ⛀㤢䘜宵황䏹熉 1125579048 2 4 GUID
title 标题,题目 1125579048 2 4 MS_Description
title 109 1125579048 2 4 MS_DisplayControl
title 1 1125579048 2 4 MS_IMEMode
title 3 1125579048 2 4 MS_IMESentMode
title title 1125579048 2 4 Name
title 1 1125579048 2 4 OrdinalPosition
title False 1125579048 2 4 Required
title 50 1125579048 2 4 Size
title title 1125579048 2 4 SourceField
title article 1125579048 2 4 SourceTable
title 10 1125579048 2 4 Type
title True 1125579048 2 4 UnicodeCompression


huolx 2004-05-08
  • 打赏
  • 举报
回复
顶顶
sqldmoexec 2004-05-08
  • 打赏
  • 举报
回复
mark
huolx 2004-05-08
  • 打赏
  • 举报
回复
zjcxc(邹建) 兄请告诉我您的mail或QQ,MSN
huolx 2004-05-08
  • 打赏
  • 举报
回复
顶顶
zjcxc 元老 2004-05-07
  • 打赏
  • 举报
回复
我初步怀疑是升迁将字段的扩展属性搬到里面去了,导致有多余信息.
zjcxc 元老 2004-05-07
  • 打赏
  • 举报
回复
--再看看下面语句的执行结果是什么?

SELECT 字段名=article.name,字段说明=isnull(g.[value],''),g.id,g.smallid,g.type,g.name
FROM syscolumns article
left join sysproperties g on article.id=g.id and article.colid=g.smallid
where article.id=object_id('article')
and article.name in('title','sourcetype')
zjcxc 元老 2004-05-07
  • 打赏
  • 举报
回复
--看看执行下面两个查询的结果是什么?

--查询1
SELECT 字段名=article.name,字段说明=isnull(g.[value],'')
FROM syscolumns article
left join sysproperties g on article.id=g.id and article.colid=g.smallid
where g.name='MS_Description'
and article.id=object_id('article')
and article.name in('title','sourcetype')


--查询2
SELECT 字段名=article.name,字段说明=isnull(g.[value],'')
FROM syscolumns article
left join sysproperties g on article.id=g.id and article.colid=g.smallid
where g.name='caption'
and article.id=object_id('article')
and article.name in('title','sourcetype')

zjcxc 元老 2004-05-07
  • 打赏
  • 举报
回复
我升迁ACCESS倒没有发现这个问题.

你试试在企业管理器--右键你的表article--看看字段sourcetype的说明中写了些什么
shareworld 2004-05-07
  • 打赏
  • 举报
回复
我说一种新的方法,看适合不适合你的需求
sp_Columns @tableName
返回一结果集,有你需要的东西
8992026 2004-05-07
  • 打赏
  • 举报
回复
有一定规律,比如:

delete sysproperties
where value is null

delete sysproperties
where value =''

delete sysproperties
where value ='false'

delete sysproperties
where value ='true'

delete sysproperties
where ISNUMERIC(value) =1

delete sysproperties
where value like '%&#%'

加载更多回复(9)

34,590

社区成员

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

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