SQL 判断字段类型语句

SQL 判断字段类型语句,第1张

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')

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/891709.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-14
下一篇 2022-05-14

发表评论

登录后才能评论

评论列表(0条)

保存