如何从MS SQL数据表中检索列默认值 [英] How to retrieve column default value from MS SQL data table

查看:106
本文介绍了如何从MS SQL数据表中检索列默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 DataAdapter.FillSchema 从MS SQL检索表的模式。不幸的是,这不会返回列的默认值。当我需要检查数百个表时,是否有一种方法可以快速高效地检索此值作为架构的一部分?

I am using DataAdapter.FillSchema to retrieve tables' schema from MS SQL. Unfortunately this doesn't return the default value for the columns. Is there a way to retrieve this value as part of the schema in a fast and efficient way as I need to examine hundreds of tables?

谢谢!

推荐答案

默认值仅在插入行时确定。

Default value is determined at the time of row insertion only.

作为替代方案,您可以利用 Information_schema

As an alternative, you can utilize Information_schema

SELECT TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT
FROM AdventureWorks2012.INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Person';

这篇关于如何从MS SQL数据表中检索列默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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