Get the App
SLTechnology News&Howtos  ›  Database  › 

How to judge the field type in SQL

Shulou Source: shulou.com Published: 2022-05-31 19:25:36 10月02日 Update

This article will explain in detail how to judge the field type in SQL. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

-- > 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 coach test' go--

Method 1

The code is as follows: select sql_variant_property (ID,'BaseType') from tb

-method 2

The code is as follows: select object_name (ID) table name, c.name field name, t.name data type, c.prec length from syscolumns c inner join systypes t on c.xusertype=t.xusertype where objectproperty (id,'IsUserTable') = 1 and id=object_id ('tb')

On how to determine the field type in SQL to share here, I hope the above content can be of some help to you, you can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Fields types code content articles methods more knowledge articles good data quality length references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Microsoft MariaDB Apple MySQL