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?
Thanks!
Default value is determined at the time of row insertion only.
As an alternative, you can utilize Information_schema
Try the following query:
There is no way you can do that by using FillSchema. For details check link below http://msdn.microsoft.com/en-us/library/229sz0y5.aspx
INFORMATION_SCHEMA is the place where you should look. INFORMATION_SCHEMA contains many system views which can show you details of database structure. for example
INFORMATION_SCHEMA.TABLES : shows you list of tables in the database INFORMATION_SCHEMA.COLUMNS : shows you list of Columns and their attributes in all tables of the database. Please look at following location for more detail.
http://msdn.microsoft.com/en-us/library/ms186778.aspx
To get default value using query you can use following query:
you should try something like this to retrieve tables schema.
EDIT: Close quote on conString