SQL Server 判断字段类型语句

2022-11-12 09:54:08
内容摘要
这篇文章主要为大家详细介绍了SQL Server 判断字段类型语句,具有一定的参考价值,可以用来参考一下。 对此感兴趣的朋友,看看idc笔记做的技术笔记!-->Title:Generating test dat
文章正文

这篇文章主要为大家详细介绍了SQL Server 判断字段类型语句,具有一定的参考价值,可以用来参考一下。

对此感兴趣的朋友,看看idc笔记做的技术笔记!

-->Title:Generating test data-->Author:wufeng4552-->Date :2009-09-25 09:56:07if object_id('tb')is not null drop table tbgocreate table tb(ID int,name text)insert tb select 1,'test'go--方法1

代码如下:

1
2
3
<code>
select sql_variant_property(ID,'BaseType') from tb
</code>
--方法2

代码如下:

1
2
3
4
5
6
7
8
9
10
<code>
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')
</code>

注:关于SQL Server 判断字段类型语句的内容就先介绍到这里,更多相关文章的可以留意

代码注释

作者:喵哥笔记

IDC笔记

学的不仅是技术,更是梦想!