Link to home
Start Free TrialLog in
Avatar of smacca
smaccaFlag for Australia

asked on

MS SQL Server database schema retrieval

I would like to retrieve the database schema and determine the following:

  * User Tables
  * Keys (primary keys, composite keys, no keys)
  * Relationships (all types)
  * Null possible

I am really desperate to retrieve this information and will award maximum points for solution.

Can someone please provide an example of how to retrieve the schema and the above information.

Cheers.
ASKER CERTIFIED SOLUTION
Avatar of Mohammed Nasman
Mohammed Nasman
Flag of Palestine, State of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SqlConnection cn = new SqlConnection("PutYourConnectionStringOverHere");
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Information_Schema.Tables where Table_Type = 'BASE TABLE'", cn");
DataTable dt = new DataTable();
da.Fill(dt);