如何在SQL中获取列的DataType [英] How to Get DataType of a Column in SQL
本文介绍了如何在SQL中获取列的DataType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨Guyz,
只是想知道如何获取以下查询的数据类型。
Hi Guyz,
Just wanted to know that how to get the data type of a for the following Query.
SELECT '345/575'
没有表只是我选择的值.. FOR TEST ..
There is no table its just the value that i have selected.. FOR TEST..
推荐答案
SELECT '123' AS t, 123 AS t2
into #tmp
SELECT TYPE_NAME(c.system_type_id) AS type FROM tempdb.sys.[columns] c WHERE c.[object_id] = object_id('tempdb.dbo.#tmp')
DROP TABLE #tmp
你可以这样做
you can do it like this
试试这个
从INFORMATION_SCHEMA.COLUMNS IC中选择DATA_TYPE,其中TABLE_NAME ='你的TableName'和COLUMN_NAME ='您的列名'
它会为您提供列的数据类型..
try this
select DATA_TYPE from INFORMATION_SCHEMA.COLUMNS IC where TABLE_NAME = 'Your TableName' and COLUMN_NAME = 'your column name'
it will give you data type of a column..
这篇关于如何在SQL中获取列的DataType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文