如何判断GUID字段?

yy2001 2003-11-30 03:35:24
如何用SQL语句判断出一个表中的GUID字段的字段名?
...全文
200 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yy2001 2003-12-03
  • 打赏
  • 举报
回复
select a.name from syscolumns a join systypes b on a.xtype=b.xusertype where b.name='VARCHAR' and a.id=object_id('表名')


如果写成上面那样,其不是把表中所有的VARCHAR类型的字段都找到了?可我要的是内容是GUID的啊?
youngby 2003-12-01
  • 打赏
  • 举报
回复
select a.name from syscolumns a join systypes b on a.xtype=b.xusertype where b.name='uniqueidentifier' and a.id=object_id('表名')


以上的方法是否限于GUID字段的类型是uniqueidentifier的,若设置的是VARCHAR呢?
就改成:

select a.name from syscolumns a join systypes b on a.xtype=b.xusertype where b.name='VARCHAR' and a.id=object_id('表名')

不管你是想查询什么的。只要把b.name='你要查询的类型'

select a.name from syscolumns a join systypes b on a.xtype=b.xusertype where b.name='你要查询的类型' and a.id=object_id('表名')


yy2001 2003-12-01
  • 打赏
  • 举报
回复
以上的方法是否限于GUID字段的类型是uniqueidentifier的,若设置的是VARCHAR呢?
zjcxc 元老 2003-12-01
  • 打赏
  • 举报
回复
楼上几位的已经可以了.
pengdali 2003-12-01
  • 打赏
  • 举报
回复
select a.name from syscolumns a join systypes b on a.xtype=b.xusertype where b.name='uniqueidentifier' and a.id=object_id('表名')
youngby 2003-11-30
  • 打赏
  • 举报
回复
or:
select a.name from syscolumns join systypes b on a.xtype=b.xtype
where b.name='uniqueidentifier' and a.id=object_id('表名')
youngby 2003-11-30
  • 打赏
  • 举报
回复
select name from syscolumns where xtype=36 and id=object_id('表名')
go
yadongfile 2003-11-30
  • 打赏
  • 举报
回复
up
yy2001 2003-11-30
  • 打赏
  • 举报
回复
没有人知道吗?

34,590

社区成员

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

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