SQL中怎么判断字段类型
这篇文章将为大家详细讲解有关SQL中怎么判断字段类型,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
-->Title:Generating test data -->Author:wufeng4552 -->Date :2009-09-25 09:56:07 if object_id('tb')is not null drop table tb go create table tb(ID int,name text) insert tb select 1,'test' go --
方法1
代码如下: select sql_variant_property(ID,'BaseType') from tb
--方法2
代码如下: select object_name(ID)表名, c.name 字段名, t.name 数据类型, c.prec 长度 from syscolumns c inner join systypes t on c.xusertype=t.xusertype where objectproperty(id,'IsUserTable')=1 and id=object_id('tb')
关于SQL中怎么判断字段类型就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。