sql server:获取列的默认值 [英] sql server : get default value of a column

查看:46
本文介绍了sql server:获取列的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我执行一个选择来获取表的结构.我想获取有关列的信息,例如其名称、是否为空或是否为主键.我做这样的事情

I execute a select to get the structure of a table. I want to get info about the columns like its name or if it's null or if it's primary key.. I do something like this

....sys.columns c...
c.precision,
c.scale,
c.is_nullable as isnullable,
c.default_object_id as columndefault,
c.is_computed as iscomputed,

但是对于默认值,我得到了 id.. 类似 454545454 的东西,但我想得到值xxxx".要搜索的表是什么或将该 id 转换为值的函数是什么.谢谢

but for default value i get the id..something like 454545454 but i want to get the value "xxxx". What is the table to search or what is the function to convert that id to the value. Thanks

推荐答案

你可以这样做(做一个 SELECT * 只是为了你可以看到所有可用的信息):

You can do this (done a SELECT * just so you can see all the info available):

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE....

这包括结果集中的COLUMN_DEFAULT"列.

This includes a "COLUMN_DEFAULT" column in the resultset.

这篇关于sql server:获取列的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆