Get database schema

I want to know how I can get information about the Sql-Database schema, such as tables, columns and their relationship between tables, etc. I know that this is possible if I execute various specific queries in the Master Database and the target database. But is there an efficient way to get the database schema?

Thanks in advance.

+7
source share
5 answers

Take a look at this project on codeplex: http://dbschemareader.codeplex.com/releases/view/71696

+6
source

You can get database metadata using the GetSchema method of the Connection class.

+3
source
+2
source

GetSchema and Schema Collections

In Connection classes, each of the managed .NET Framework providers implements the GetSchema method, which is used to retrieve schema information about the connected database, and the schema information returned from the GetSchema method is presented as a DataTable. The GetSchema method is an overloaded method that provides optional parameters for specifying the returned collection of schemas and limiting the amount of information returned.

http://msdn.microsoft.com/en-us/library/ms254934(v=vs.110).aspx

0
source

Use the GetSchema SqlConnection class:

DataTable t = _conn.GetSchema("Tables") ;

For more information, read the MSDN article Extract Database Schema Information (ADO.NET) .

0
source

All Articles